43 _cvData.push_back(
CV(position, val, type));
56 auto realCVs =
_cvData.size() - 2;
62 auto lastIndex =
_cvData.size() - 1;
74 for (
unsigned int i = 1; i <
_cvData.size() - 1; i++) {
79 for (
unsigned int i = 0; i <
_cvData.size() - 1; i++) {
98 const int numPoints =
static_cast<int>(
_cvData.size());
100 int index =
static_cast<int>(std::upper_bound(cvDataBegin, cvDataBegin + numPoints,
CV(param, T(),
kLinear),
cvLessThan) - cvDataBegin);
101 index = std::max(1, std::min(index, numPoints - 1));
103 const auto t0 =
_cvData[index - 1]._pos;
104 const T k0 =
_cvData[index - 1]._val;
106 const auto t1 =
_cvData[index]._pos;
107 const T k1 =
_cvData[index]._val;
113 double u = (param - t0) / (t1 - t0);
114 return k0 + u * (k1 - k0);
117 double u = (param - t0) / (t1 - t0);
118 return k0 * (u - 1) * (u - 1) * (2 * u + 1) + k1 * u * u * (3 - 2 * u);
122 double x = param -
_cvData[index - 1]._pos;
126 T d1 =
_cvData[index - 1]._deriv;
128 return (x * (delta * (3 * h - 2 * x) * x + h * (-h + x) * (-(d1 * h) + (d1 + d2) * x))) / (h * h * h) + y;
143 const int numPoints =
static_cast<int>(
_cvData.size());
145 int index =
static_cast<int>(std::upper_bound(cvDataBegin, cvDataBegin + numPoints,
CV(param, T(),
kLinear),
cvLessThan) - cvDataBegin);
146 index = std::max(1, std::min(index, numPoints - 1));
148 const auto t0 =
_cvData[index - 1]._pos;
149 const double k0 =
comp(
_cvData[index - 1]._val, channel);
151 const auto t1 =
_cvData[index]._pos;
152 const double k1 =
comp(
_cvData[index]._val, channel);
158 double u = (param - t0) / (t1 - t0);
159 return k0 + u * (k1 - k0);
164 double u = (param - t0) / (t1 - t0);
165 return k0 * (u - 1) * (u - 1) * (2 * u + 1) + k1 * u * u * (3 - 2 * u);
170 double x = param -
_cvData[index - 1]._pos;
174 double d1 =
comp(
_cvData[index - 1]._deriv, channel);
177 return (x * (delta * (3 * h - 2 * x) * x + h * (-h + x) * (-(d1 * h) + (d1 + d2) * x))) / (h * h * h) + y;
190 int numPoints =
static_cast<int>(
_cvData.size());
191 int index =
static_cast<int>(std::upper_bound(cvDataBegin, cvDataBegin + numPoints,
CV(param, T(),
kLinear),
cvLessThan) - cvDataBegin);
192 index = std::max(1, std::min(index, numPoints - 1));
215 for (
int i = 0; i < 3; i++) {
Interpolation curve class for double->double and double->Vec3D.
InterpType
Supported interpolation types.
void preparePoints()
Prepares points for evaluation (sorts and computes boundaries, clamps extrema)
T getValue(double param) const
Evaluates curve and returns full value.
static bool cvLessThan(const CV &cv1, const CV &cv2)
CV Parameter ordering (cv1._pos < cv2._pos)
void addPoint(double position, const T &val, InterpType type)
Adds a point to the curve.
std::vector< CV > _cvData
static double comp(const T &val, int i)
Returns a component of the given value.
double getChannelValue(double param, int channel) const
CV getLowerBoundCV(double param) const
static bool interpTypeValid(InterpType interp)
Returns whether the given interpolation type is supported.
void clampCurveSegment(const T &delta, T &d1, T &d2)
Performs hermite derivative clamping in canonical space.
double clamp(double x, double lo, double hi)
Vec< double, 3, false > Vec3d