UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

17 lines (16 loc) 528 B
/** * Evaluates p'(x), the first derivative of the cubic stored at * coeffs[base..base+3]: * * p'(x) = coeffs[base+1] * + 2 * coeffs[base+2] * x * + 3 * coeffs[base+3] * x^2 * * @param {number[]|Float32Array|Float64Array} coeffs * @param {number} base index of the constant term (coefficient of x^0) * @param {number} x * @returns {number} */ export function polynomial_cubic_derivative_eval(coeffs, base, x) { return coeffs[base + 1] + x * (2 * coeffs[base + 2] + x * 3 * coeffs[base + 3]); }