function casteljauPoint2D(curve, t) {
    // Step 1
    const Ax = ((1 - t) * curve.points[0].x) + (t * curve.points[1].x);
    const Ay = ((1 - t) * curve.points[0].y) + (t * curve.points[1].y);
    const Bx = ((1 - t) * curve.points[1].x) + (t * curve.points[2].x);
    const By = ((1 - t) * curve.points[1].y) + (t * curve.points[2].y);
    const Cx = ((1 - t) * curve.points[2].x) + (t * curve.points[3].x);
    const Cy = ((1 - t) * curve.points[2].y) + (t * curve.points[3].y);

    // Step 2
    const Dx = ((1 - t) * Ax) + (t * Bx);
    const Dy = ((1 - t) * Ay) + (t * By);
    const Ex = ((1 - t) * Bx) + (t * Cx);
    const Ey = ((1 - t) * By) + (t * Cy);

    // Step 3
    const Px = ((1 - t) * Dx) + (t * Ex);
    const Py = ((1 - t) * Dy) + (t * Ey);

    return new THREE.Vector2(
        Number(Math.abs(Px).toFixed(1)),
        Number(Math.abs(Py).toFixed(1)),
    );
}
// 2D implementation of casteljau's algorithm
2D implementation of casteljau's algorithm
2D implementation of casteljau ' s algorithm
function casteljauPoint2D(curve, t) {
    const Ax = ((1 - t) * curve.points[0].x) + (t * curve.points[1].x);
    const Ay = ((1 - t) * curve.points[0].y) + (t * curve.points[1].y);
    const Bx = ((1 - t) * curve.points[1].x) + (t * curve.points[2].x);
    const By = ((1 - t) * curve.points[1].y) + (t * curve.points[2].y);
    const Cx = ((1 - t) * curve.points[2].x) + (t * curve.points[3].x);
    const Cy = ((1 - t) * curve.points[2].y) + (t * curve.points[3].y);
    const Dx = ((1 - t) * Ax) + (t * Bx);
    const Dy = ((1 - t) * Ay) + (t * By);
    const Ex = ((1 - t) * Bx) + (t * Cx);
    const Ey = ((1 - t) * By) + (t * Cy);
    const Px = ((1 - t) * Dx) + (t * Ex);
    const Py = ((1 - t) * Dy) + (t * Ey);
    return new THREE.Vector2(
        Number(Math.abs(Px).toFixed(1)),
        Number(Math.abs(Py).toFixed(1)),
    );
}
function casteljauPoint2D ( curve , t ) { const Ax = ( ( 1 - t ) * curve . points [ 0 ] . x ) + ( t * curve . points [ 1 ] . x ) ; const Ay = ( ( 1 - t ) * curve . points [ 0 ] . y ) + ( t * curve . points [ 1 ] . y ) ; const Bx = ( ( 1 - t ) * curve . points [ 1 ] . x ) + ( t * curve . points [ 2 ] . x ) ; const By = ( ( 1 - t ) * curve . points [ 1 ] . y ) + ( t * curve . points [ 2 ] . y ) ; const Cx = ( ( 1 - t ) * curve . points [ 2 ] . x ) + ( t * curve . points [ 3 ] . x ) ; const Cy = ( ( 1 - t ) * curve . points [ 2 ] . y ) + ( t * curve . points [ 3 ] . y ) ; const Dx = ( ( 1 - t ) * Ax ) + ( t * Bx ) ; const Dy = ( ( 1 - t ) * Ay ) + ( t * By ) ; const Ex = ( ( 1 - t ) * Bx ) + ( t * Cx ) ; const Ey = ( ( 1 - t ) * By ) + ( t * Cy ) ; const Px = ( ( 1 - t ) * Dx ) + ( t * Ex ) ; const Py = ( ( 1 - t ) * Dy ) + ( t * Ey ) ; return new THREE . Vector2 ( Number ( Math . abs ( Px ) . toFixed ( 1 ) ) , Number ( Math . abs ( Py ) . toFixed ( 1 ) ) , ) ; }
2D implementation of casteljau's algorithm
2D implementation of casteljau ' s algorithm
// Step 1 // Step 2 // Step 3