CubicSpline.h 927 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef CUBICSPLINE_H
  2. #define CUBICSPLINE_H
  3. #include <vector>
  4. #include <utility>
  5. #include <tuple>
  6. #include <map>
  7. #include <Color.h>
  8. class CubicSpline
  9. {
  10. /// contains x, y and y' of each interpolation point
  11. std::vector<std::tuple<float, float, float>> points;
  12. bool useSlopes;
  13. public:
  14. CubicSpline(const std::vector<std::pair<float, float>>& dataPoints,
  15. bool useSlopes, bool minSlopes);
  16. float interpolateAt(float x);
  17. };
  18. class ColorSpline
  19. {
  20. ///
  21. /// \brief at each position, stores the color value and the channel-wise
  22. /// slopes of the spline.
  23. ///
  24. std::map<float, std::pair<RGBColorf, RGBColorf>> points;
  25. bool useSlopes;
  26. public:
  27. ColorSpline(void) = default;
  28. ColorSpline(const std::vector<std::pair<float, RGBColorf>>& dataPoints,
  29. bool useSlopes, bool minSlopes);
  30. RGBColorf interpolateAt(float x) const;
  31. };
  32. #endif // CUBICSPLINE_H