Cheetah Software  1.0
Interpolate Namespace Reference

Functions

template<typename y_t , typename x_t >
y_t lerp (y_t y0, y_t yf, x_t x)
 
template<typename y_t , typename x_t >
y_t cubicBezier (y_t y0, y_t yf, x_t x)
 
template<typename y_t , typename x_t >
y_t cubicBezierFirstDerivative (y_t y0, y_t yf, x_t x)
 
template<typename y_t , typename x_t >
y_t cubicBezierSecondDerivative (y_t y0, y_t yf, x_t x)
 

Function Documentation

template<typename y_t , typename x_t >
y_t Interpolate::cubicBezier ( y_t  y0,
y_t  yf,
x_t  x 
)

Cubic bezier interpolation between y0 and yf. x is between 0 and 1

Definition at line 29 of file Interpolation.h.

29  {
30  static_assert(std::is_floating_point<x_t>::value,
31  "must use floating point value");
32  assert(x >= 0 && x <= 1);
33  y_t yDiff = yf - y0;
34  x_t bezier = x * x * x + x_t(3) * (x * x * (x_t(1) - x));
35  return y0 + bezier * yDiff;
36 }

+ Here is the caller graph for this function:

template<typename y_t , typename x_t >
y_t Interpolate::cubicBezierFirstDerivative ( y_t  y0,
y_t  yf,
x_t  x 
)

Cubic bezier interpolation derivative between y0 and yf. x is between 0 and 1

Definition at line 43 of file Interpolation.h.

43  {
44  static_assert(std::is_floating_point<x_t>::value,
45  "must use floating point value");
46  assert(x >= 0 && x <= 1);
47  y_t yDiff = yf - y0;
48  x_t bezier = x_t(6) * x * (x_t(1) - x);
49  return bezier * yDiff;
50 }

+ Here is the caller graph for this function:

template<typename y_t , typename x_t >
y_t Interpolate::cubicBezierSecondDerivative ( y_t  y0,
y_t  yf,
x_t  x 
)

Cubic bezier interpolation derivative between y0 and yf. x is between 0 and 1

Definition at line 57 of file Interpolation.h.

57  {
58  static_assert(std::is_floating_point<x_t>::value,
59  "must use floating point value");
60  assert(x >= 0 && x <= 1);
61  y_t yDiff = yf - y0;
62  x_t bezier = x_t(6) - x_t(12) * x;
63  return bezier * yDiff;
64 }

+ Here is the caller graph for this function:

template<typename y_t , typename x_t >
y_t Interpolate::lerp ( y_t  y0,
y_t  yf,
x_t  x 
)

Linear interpolation between y0 and yf. x is between 0 and 1

Definition at line 18 of file Interpolation.h.

18  {
19  static_assert(std::is_floating_point<x_t>::value,
20  "must use floating point value");
21  assert(x >= 0 && x <= 1);
22  return y0 + (yf - y0) * x;
23 }

+ Here is the caller graph for this function: