magma.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 Joe Graus <jgraus@gmu.edu>, Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_MAGMA_H
  9. #define IGL_MAGMA_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl {
  13. // Magma colormap -- a perceptually uniform sequential colormap
  14. //
  15. // Inputs:
  16. // m number of colors
  17. // Outputs:
  18. // J m by list of RGB colors between 0 and 1
  19. //
  20. // Wrapper for directly computing [r,g,b] values for a given factor f between
  21. // 0 and 1
  22. //
  23. // Inputs:
  24. // f factor determining color value as if 0 was min and 1 was max
  25. // Outputs:
  26. // r red value
  27. // g green value
  28. // b blue value
  29. template <typename T>
  30. IGL_INLINE void magma(const T f, T * rgb);
  31. template <typename T>
  32. IGL_INLINE void magma(const T f, T & r, T & g, T & b);
  33. // Inputs:
  34. // Z #Z list of factors
  35. // normalize whether to normalize Z to be tightly between [0,1]
  36. // Outputs:
  37. // C #C by 3 list of rgb colors
  38. template <typename DerivedZ, typename DerivedC>
  39. IGL_INLINE void magma(
  40. const Eigen::PlainObjectBase<DerivedZ> & Z,
  41. const bool normalize,
  42. Eigen::PlainObjectBase<DerivedC> & C);
  43. // Inputs:
  44. // min_z value at black
  45. // max_z value at yellow
  46. template <typename DerivedZ, typename DerivedC>
  47. IGL_INLINE void magma(
  48. const Eigen::PlainObjectBase<DerivedZ> & Z,
  49. const double min_Z,
  50. const double max_Z,
  51. Eigen::PlainObjectBase<DerivedC> & C);
  52. };
  53. #ifndef IGL_STATIC_LIBRARY
  54. # include "magma.cpp"
  55. #endif
  56. #endif