MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
interpolator.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <mbgl/util/range.hpp>
6 
7 namespace mbgl {
8 namespace style {
9 namespace expression {
10 
12 public:
13  ExponentialInterpolator(double base_) : base(base_) {}
14 
15  double base;
16 
17  double interpolationFactor(const Range<double>& inputLevels, const double input) const {
18  return util::interpolationFactor(static_cast<float>(base),
19  Range<float> {
20  static_cast<float>(inputLevels.min),
21  static_cast<float>(inputLevels.max)
22  },
23  static_cast<float>(input));
24  }
25 
26  bool operator==(const ExponentialInterpolator& rhs) const {
27  return base == rhs.base;
28  }
29 };
30 
32 public:
33  CubicBezierInterpolator(double x1_, double y1_, double x2_, double y2_) : ub(x1_, y1_, x2_, y2_) {}
34 
35  double interpolationFactor(const Range<double>& inputLevels, const double input) const {
37  Range<float> {
38  static_cast<float>(inputLevels.min),
39  static_cast<float>(inputLevels.max)
40  },
41  static_cast<float>(input)),
42  1e-6);
43  }
44 
45  bool operator==(const CubicBezierInterpolator& rhs) const {
46  return ub == rhs.ub;
47  }
48 
50 };
51 
53 
54 } // namespace expression
55 } // namespace style
56 } // namespace mbgl
double interpolationFactor(const Range< double > &inputLevels, const double input) const
CubicBezierInterpolator(double x1_, double y1_, double x2_, double y2_)
bool operator==(const CubicBezierInterpolator &rhs) const
double interpolationFactor(const Range< double > &inputLevels, const double input) const
bool operator==(const ExponentialInterpolator &rhs) const
variant< ExponentialInterpolator, CubicBezierInterpolator > Interpolator
float interpolationFactor(float base, Range< float > range, float z)
Definition: actor.hpp:15
mapbox::util::variant< T... > variant
Definition: variant.hpp:17
double solve(double x, double epsilon) const
Definition: unitbezier.hpp:114