|
#include "Lib3ds_math.h"
Lib3ds_math::Lib3ds_math()
{
}
float Lib3ds_math::lib3ds_math_ease(float fp, float fc, float fn, float ease_from, float ease_to) {
double s, step;
double tofrom;
double a;
s = step = (float)(fc - fp) / (fn - fp);
tofrom = ease_to + ease_from;
if (tofrom != 0.0) {
if (tofrom > 1.0) {
ease_to = (float)(ease_to / tofrom);
ease_from = (float)(ease_from / tofrom);
}
a = 1.0 / (2.0 - (ease_to + ease_from));
if (step < ease_from) s = a / ease_from * step * step;
else {
if ((1.0 - ease_to) <= step) {
step = 1.0 - step;
s = 1.0 - a / ease_to * step * step;
} else {
s = ((2.0 * step) - ease_from) * a;
}
}
}
return((float)s);
}
void Lib3ds_math::lib3ds_math_cubic_interp(float *v, float *a, float *p, float *q, float *b, int n, float t) {
float x, y, z, w;
int i;
x = 2 * t * t * t - 3 * t * t + 1;
y = -2 * t * t * t + 3 * t * t;
z = t * t * t - 2 * t * t + t;
w = t * t * t - t * t;
for (i = 0; i < n; ++i) {
v[i] = x * a[i] + y * b[i] + z * p[i] + w * q[i];
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.