bezier function
Performs a bezier interpolation with two control points
@param {vec3} out the receiving vector
@param {ReadonlyVec3} a the first operand
@param {ReadonlyVec3} b the second operand
@param {ReadonlyVec3} c the third operand
@param {ReadonlyVec3} d the fourth operand
@param {Number} t interpolation amount, in the range 0-1
, between the two inputs
@returns {vec3} out
Implementation
List<double> bezier(out, a, b, c, d, t) {
final inverseFactor = 1 - t;
final inverseFactorTimesTwo = inverseFactor * inverseFactor;
final factorTimes2 = t * t;
final factor1 = inverseFactorTimesTwo * inverseFactor;
final factor2 = 3 * t * inverseFactorTimesTwo;
final factor3 = 3 * factorTimes2 * inverseFactor;
final factor4 = factorTimes2 * t;
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
return out;
}