Motive Animation System
An open source project by FPL.
 All Classes Functions Variables Typedefs Friends Pages
motive::CubicCurve Class Reference

Represent a cubic polynomial of the form, c_[3] * x^3 + c_[2] * x^2 + c_[1] * x + c_[0]. More...

#include <curve.h>

Detailed Description

Represent a cubic polynomial of the form, c_[3] * x^3 + c_[2] * x^2 + c_[1] * x + c_[0].

Public Member Functions

 CubicCurve (const float c3, const float c2, const float c1, const float c0)
 
 CubicCurve (const float *c)
 
 CubicCurve (const CubicInit &init)
 
void Init (const CubicInit &init)
 
void ShiftLeft (const float x_shift)
 
void ShiftRight (const float x_shift)
 Shift the curve along the x-axis: x_shift to the right.
 
void ShiftUp (float y_offset)
 Shift the curve along the y-axis by y_offset: y_offset up the y-axis.
 
void ScaleUp (float y_scale)
 Scale the curve along the y-axis by a factor of y_scale.
 
float Evaluate (const float x) const
 
float Derivative (const float x) const
 
float SecondDerivative (const float x) const
 
float ThirdDerivative (const float x) const
 
bool UniformCurvature (const Range &x_limits) const
 
float Epsilon () const
 
float Coeff (int i) const
 Returns the coefficient for x to the ith power.
 
void SetCoeff (int i, float coeff)
 Overrides the coefficent for x to the ith power.
 
int NumCoeff () const
 Returns the number of coefficients in this curve.
 
bool operator== (const CubicCurve &rhs) const
 Equality. Checks for exact match. Useful for testing.
 
bool operator!= (const CubicCurve &rhs) const
 
std::string Text () const
 A string with the cubic equation. Useful for debugging.
 

Static Public Attributes

static const int kNumCoeff = 4
 

Member Function Documentation

float motive::CubicCurve::Derivative ( const float  x) const
inline

Return the cubic function's slope at x. f'(x) = 3*c3*x^2 + 2*c2*x + c1

float motive::CubicCurve::Epsilon ( ) const
inline

Return a value below which floating point precision is unreliable. If we're testing for zero, for instance, we should test against this Epsilon().

float motive::CubicCurve::Evaluate ( const float  x) const
inline

Return the cubic function's value at x. f(x) = c3*x^3 + c2*x^2 + c1*x + c0

Take advantage of multiply-and-add instructions that are common on FPUs.

float motive::CubicCurve::SecondDerivative ( const float  x) const
inline

Return the cubic function's second derivative at x. f''(x) = 6*c3*x + 2*c2

void motive::CubicCurve::ShiftLeft ( const float  x_shift)

Shift the curve along the x-axis: x_shift to the left. That is x_shift becomes the curve's x=0.

float motive::CubicCurve::ThirdDerivative ( const float  x) const
inline

Return the cubic function's constant third derivative. Even though x is unused, we pass it in for consistency with other curve classes. f'''(x) = 6*c3

bool motive::CubicCurve::UniformCurvature ( const Range x_limits) const

Returns true if always curving upward or always curving downward on the specified x_limits. That is, returns true if the second derivative has the same sign over all of x_limits.


The documentation for this class was generated from the following file: