Field3D
|
Implements a simple function curve where samples of type T can be added along a 1D axis. Once samples exist they can be interpolated using the linear() call. More...
#include <Curve.h>
Classes | |
struct | CheckTEqual |
Used when finding values in the m_samples vector. More... | |
struct | CheckTGreaterThan |
Used when finding values in the m_samples vector. More... | |
Public Types | |
typedef std::pair< float, T > | Sample |
typedef std::vector< Sample > | SampleVec |
Public Member Functions | |
void | addSample (const float t, const T &value) |
Adds a sample point to the curve. | |
void | clear () |
Clears all samples in curve. | |
T | linear (const float t) const |
Linearly interpolates a value from the curve. | |
size_t | numSamples () const |
Returns the number of samples in the curve. | |
const SampleVec & | samples () const |
Returns a const reference to the samples in the curve. | |
Private Member Functions | |
T | defaultReturnValue () const |
The default return value is used when no sample points are available. This defaults to zero, but for some types (for example Quaternion), We need more arguments to the constructor. In these cases the method is specialized for the given T type. | |
Imath::Matrix44< float > | defaultReturnValue () const |
Imath::Matrix44< double > | defaultReturnValue () const |
T | lerp (const Sample &lower, const Sample &upper, const float t) const |
The default implementation for linear interpolation. Works for all classes for which Imath::lerp is implemented (i.e float/double, V2f, V3f). For other types this method needs to be specialized. | |
Private Attributes | |
SampleVec | m_samples |
Stores the samples that define the curve. Sample insertion ensures that the samples are sorted according to Sample.first. | |
Implements a simple function curve where samples of type T can be added along a 1D axis. Once samples exist they can be interpolated using the linear() call.
typedef std::pair<float, T> Curve< T >::Sample |
void Curve< T >::addSample | ( | const float | t, |
const T & | value ) |
Adds a sample point to the curve.
Definition at line 189 of file Curve.h.
References m_samples.
T Curve< T >::linear | ( | const float | t | ) | const |
Linearly interpolates a value from the curve.
t | Position along curve |
Definition at line 216 of file Curve.h.
References defaultReturnValue(), lerp(), and m_samples.
|
inline |
|
inline |
|
inlineprivate |
The default return value is used when no sample points are available. This defaults to zero, but for some types (for example Quaternion), We need more arguments to the constructor. In these cases the method is specialized for the given T type.
Definition at line 167 of file Curve.h.
Referenced by linear().
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
Stores the samples that define the curve. Sample insertion ensures that the samples are sorted according to Sample.first.
Definition at line 180 of file Curve.h.
Referenced by addSample(), and linear().