29 #ifndef __MATH_EXTRAPOLATE_H__
30 #define __MATH_EXTRAPOLATE_H__
50 template<
class type >
85 template<
class type >
88 startTime = duration = 0.0f;
89 memset( &startValue, 0,
sizeof( startValue ) );
90 memset( &baseSpeed, 0,
sizeof( baseSpeed ) );
91 memset( &speed, 0,
sizeof( speed ) );
93 currentValue = startValue;
101 template<
class type >
103 this->extrapolationType = extrapolationType;
104 this->startTime = startTime;
105 this->duration = duration;
106 this->startValue = startValue;
107 this->baseSpeed = baseSpeed;
110 currentValue = startValue;
118 template<
class type >
122 if ( time == currentTime ) {
128 if ( time < startTime ) {
133 time = startTime + duration;
136 switch( extrapolationType & ~EXTRAPOLATION_NOSTOP ) {
138 deltaTime = ( time - startTime ) * 0.001
f;
139 currentValue = startValue + deltaTime * baseSpeed;
143 deltaTime = ( time - startTime ) * 0.001
f;
144 currentValue = startValue + deltaTime * ( baseSpeed + speed );
149 currentValue = startValue;
151 deltaTime = ( time - startTime ) / duration;
152 s = ( 0.5f * deltaTime * deltaTime ) * ( duration * 0.001
f );
153 currentValue = startValue + deltaTime * baseSpeed + s * speed;
159 currentValue = startValue;
161 deltaTime = ( time - startTime ) / duration;
162 s = ( deltaTime - ( 0.5f * deltaTime * deltaTime ) ) * ( duration * 0.001f );
163 currentValue = startValue + deltaTime * baseSpeed + s * speed;
169 currentValue = startValue;
171 deltaTime = ( time - startTime ) / duration;
173 currentValue = startValue + deltaTime * baseSpeed + s * speed;
179 currentValue = startValue;
181 deltaTime = ( time - startTime ) / duration;
183 currentValue = startValue + deltaTime * baseSpeed + s * speed;
196 template<
class type >
200 if ( time < startTime || !duration ) {
201 return ( startValue - startValue );
205 return ( startValue - startValue );
208 switch( extrapolationType & ~EXTRAPOLATION_NOSTOP ) {
213 return baseSpeed + speed;
216 deltaTime = ( time - startTime ) / duration;
218 return baseSpeed + s * speed;
221 deltaTime = ( time - startTime ) / duration;
222 s = 1.0f - deltaTime;
223 return baseSpeed + s * speed;
226 deltaTime = ( time - startTime ) / duration;
228 return baseSpeed + s * speed;
231 deltaTime = ( time - startTime ) / duration;
233 return baseSpeed + s * speed;
GLsizei const GLfloat * value
GLuint GLuint GLsizei GLenum type
static const float HALF_PI
static float Sin(float a)
static const float SQRT_1OVER2
static float Cos(float a)