114 template<
typename Control>
139 "Control points must have monotonically increasing times.");
177 return control.
size();
196 int N = control.
size();
201 c = control[
iWrap(i, N)];
207 int wraps = (N + 1 - i) / N;
208 int j = (i + wraps * N) % N;
232 c = control[1] * float(i) + control[0] * float(1 - i);
240 t = dt * i + time[0];
252 float dt =
time[N - 1] -
time[N - 2];
256 c = control[N - 1] * float(i - N + 2) + control[N - 2] * -float(i - N + 1);
265 t = time[N - 1] + dt * (i - N + 1);
286 for (
int j = 0; j < N; ++j) {
300 virtual void correct(Control& A)
const { (void)A; }
314 for (
int i = 0; i <
time.
size(); ++i) {
331 virtual Any toAny(
const std::string& myName)
const {
336 a[
"control"] =
Any(control);
376 const Control& p0 = p[0];
377 const Control& p1 = p[1];
378 const Control& p2 = p[2];
379 const Control& p3 = p[3];
385 const float a = (s - t[1]) / (t[2] - t[1]);
386 sum = p1 * (1.0f - a) + p2 * a;
391 float dt0 = t[1] - t[0];
392 float dt1 = t[2] - t[1];
393 float dt2 = t[3] - t[2];
398 Vector4 uvec((
float)(u*u*u), (
float)(u*u), (
float)u, 1.0f);
401 const Vector4& weights = uvec * basis;
409 float x = (dt0 + dt1) * 0.5f;
414 const Control& dp0 = p1 + (p0*-1.0f);
415 const Control& dp1 = p2 + (p1*-1.0f);
416 const Control& dp2 = p3 + (p2*-1.0f);
418 const Control& dp1n1 = dp1 * n1;
419 const Control& tan1 = dp0 * n0 + dp1n1;
420 const Control& tan2 = dp1n1 + dp2 * n2;
void computeIndex(float s, int &i, float &u) const
Definition: SplineBase.cpp:90
void computeIndexInBounds(float s, int &i, float &u) const
Definition: SplineBase.cpp:61
Definition: SplineExtrapolationMode.h:66
virtual void correct(Control &A) const
Definition: Spline.h:300
SplineExtrapolationMode extrapolationMode
Definition: Spline.h:33
bool getIfPresent(const std::string &s, ValueType &v)
Definition: Any.h:989
Control zero
Definition: Spline.h:118
void resize(size_t n, bool shrinkIfNecessary=true)
Definition: Array.h:490
float finalInterval
Definition: Spline.h:42
virtual Any toAny(const std::string &myName) const
Definition: Spline.h:331
virtual ~SplineBase()
Definition: Spline.h:51
void getControl(int i, float &t, Control &c) const
Definition: Spline.h:195
bool any(float x)
Definition: g3dmath.h:424
const T & last() const
Definition: Array.h:923
Array< float > time
Definition: Spline.h:26
virtual void ensureShortestPath(Control *A, int N) const
Definition: Spline.h:297
Spline(const Any &any)
Definition: Spline.h:324
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
SplineBase()
Definition: Spline.h:46
Control evaluate(float s) const
Definition: Spline.h:348
int size() const
Definition: Spline.h:175
void getControls(int i, float *T, Control *A, int N) const
Definition: Spline.h:285
float getFinalInterval() const
Definition: SplineBase.cpp:6
void append(float t, const Control &c)
Definition: Spline.h:137
static Matrix4 computeBasis()
Definition: SplineBase.cpp:22
Easy loading and saving of human-readable configuration files.
Definition: Any.h:184
#define debugAssert(exp)
Definition: debugAssert.h:160
void append(const Control &c)
Definition: Spline.h:149
void clear(bool shrink=true)
Definition: Array.h:407
Definition: SplineExtrapolationMode.h:62
virtual void init(AnyTableReader &propertyTable)
Definition: Spline.h:303
int size() const
Definition: Array.h:430
float duration() const
Definition: SplineBase.cpp:52
int iWrap(int val, int hi)
Definition: g3dmath.h:594
void verifyDone() const
Definition: AnyTableReader.cpp:33
Array< Control > control
Definition: Spline.h:124
SplineInterpolationMode interpolationMode
Definition: Spline.h:44
void clear()
Definition: Spline.h:168
G3D::int16 x
Definition: Vector2int16.h:37
void append(const T &value)
Definition: Array.h:583
#define alwaysAssertM(exp, message)
Definition: debugAssert.h:165
Spline()
Definition: Spline.h:126