/**
 * 1D
 * Cubic spline.
 * The result is [v0, m0, v1, m1] where X are values are M are tangents.
 * @param {Float32Array|number[]} result where to put results
 * @param {number} result_offset offset to start writing at in result array
 * @param {number} result_stride how far to step between each written value. Necessary for N-dimensional curves where we want to interleave multiple curves together, such as for color or quaternions
 * @param {number} p0
 * @param {number} p1
 * @param {number} p2
 * @param {number} p3
 * @see spline3_hermite_to_bezier
 */
export function spline3_bezier_to_hermite(
    result,
    result_offset,
    result_stride,
    p0, p1, p2, p3,
) {

    // see https://github.com/krishauser/Klampt/blob/0ed16608a3eceee59d04383a17c207ebc33a399f/Python/klampt/math/spline.py#L133

    const TENSION_FACTOR = 3;

    const v0 = (p1 - p0) * TENSION_FACTOR;
    const v1 = (p3 - p2) * TENSION_FACTOR;

    result[result_offset + 0 * result_stride] = p0;
    result[result_offset + 1 * result_stride] = v0;
    result[result_offset + 2 * result_stride] = p3;
    result[result_offset + 3 * result_stride] = v1;

}