jet.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_JET_H
  9. #define IGL_JET_H
  10. #include "igl_inline.h"
  11. //#ifndef IGL_NO_EIGEN
  12. # include <Eigen/Dense>
  13. //#endif
  14. namespace igl
  15. {
  16. /// Jet colormap like MATLAB's jet.
  17. ///
  18. /// \note that we actually use the Turbo colormap instead, since jet is a bad colormap:
  19. /// https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
  20. ///
  21. /// Wrapper for directly computing [r,g,b] values for a given factor f between
  22. /// 0 and 1
  23. ///
  24. /// @param[in] f factor determining color value as if 0 was min and 1 was max
  25. /// @param[out] rgb resulting rgb color
  26. /// - r red value
  27. /// - g green value
  28. /// - b blue value
  29. template <typename T>
  30. IGL_INLINE void jet(const T f, T * rgb);
  31. /// \overload
  32. template <typename T>
  33. IGL_INLINE void jet(const T f, T & r, T & g, T & b);
  34. /// \overload
  35. /// @param[in] Z #Z list of factors
  36. /// @param[in] normalize whether to normalize Z to be tightly between [0,1]
  37. /// @param[out] C #C by 3 list of rgb colors
  38. template <typename DerivedZ, typename DerivedC>
  39. IGL_INLINE void jet(
  40. const Eigen::MatrixBase<DerivedZ> & Z,
  41. const bool normalize,
  42. Eigen::PlainObjectBase<DerivedC> & C);
  43. /// \overload
  44. /// @param[in] min_z value at blue
  45. /// @param[in] max_z value at red
  46. template <typename DerivedZ, typename DerivedC>
  47. IGL_INLINE void jet(
  48. const Eigen::MatrixBase<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 "jet.cpp"
  55. #endif
  56. #endif