typegraph/scripts/generic/hermite.gml

18 lines
575 B
Plaintext
Raw Normal View History

///hermite(x0, dx0, x1, dx1, t)
/**
* hermite :: Real -> Real -> Real -> Real -> Real -> Real
*
* Cubic Hermite interpolation between `x0` and `x1` with tangents `dx0` and `dx1` given a time 0 <= `t` <= 1.
*
* @param x0 the value of x at t=0
* @param dx0 the tangent of x at t=0
* @param x1 the value of x at t=1
* @param dx1 the tangent of x at t=1
* @param t the interpolation parameter 0<=t<=1
* @returns the value x(t)
*/
var t = argument4, t2 = t*t, t3 = t2*t;
return (2*t3-3*t2+1)*argument0+(t3-2*t2+t)*argument1+(-2*t3+3*t2)*argument2+(t3-t2)*argument3;