parula.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <[email protected]>
  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_PARULA_H
  9. #define IGL_PARULA_H
  10. #include "igl_inline.h"
  11. //#ifndef IGL_NO_EIGEN
  12. # include <Eigen/Dense>
  13. //#endif
  14. namespace igl
  15. {
  16. /// Parula colormap like MATLAB's parula
  17. ///
  18. /// @param[in] f factor determining color value as if 0 was min and 1 was max
  19. /// @param[out] rgb resulting rgb color
  20. /// - r red value
  21. /// - g green value
  22. /// - b blue value
  23. template <typename T>
  24. IGL_INLINE void parula(const T f, T * rgb);
  25. /// \overload
  26. template <typename T>
  27. IGL_INLINE void parula(const T f, T & r, T & g, T & b);
  28. /// \overload
  29. /// @param[in] Z #Z list of factors
  30. /// @param[in] normalize whether to normalize Z to be tightly between [0,1]
  31. /// @param[out] C #C by 3 list of rgb colors
  32. template <typename DerivedZ, typename DerivedC>
  33. IGL_INLINE void parula(
  34. const Eigen::MatrixBase<DerivedZ> & Z,
  35. const bool normalize,
  36. Eigen::PlainObjectBase<DerivedC> & C);
  37. /// \overload
  38. /// @param[in] min_z value at blue
  39. /// @param[in] max_z value at red
  40. template <typename DerivedZ, typename DerivedC>
  41. IGL_INLINE void parula(
  42. const Eigen::MatrixBase<DerivedZ> & Z,
  43. const double min_Z,
  44. const double max_Z,
  45. Eigen::PlainObjectBase<DerivedC> & C);
  46. };
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "parula.cpp"
  49. #endif
  50. #endif