Find a point inside a bezier curve

Hi Right now I'm drawing a triangle within a line to define the orientation of the line. However, now I need to do the same to a curve using bezier, but don't find the way to pick that point in the curve, for example in the 33% of the curve. Here my code:

        point1x = pos_1.x+(pos_2.x-pos_1.x)/4*3;
        point1y = pos_1.y+(pos_2.y-pos_1.y)/4*3;
        var toy = point1y;
        var fromy = pos_1.y;
        var tox = point1x;
        var fromx = pos_1.x;

        var angle = Math.atan2(toy-fromy,tox-fromx);

        var pointBx = tox-(headlen+30)*Math.cos(angle+Math.PI/6);
        var pointBy = toy-(headlen+30)*Math.sin(angle+Math.PI/6);

        var point2x = tox-headlen*Math.cos(angle-Math.PI/6);
        var point2y = toy-headlen*Math.sin(angle-Math.PI/6);
        var point3x = tox-headlen*Math.cos(angle+Math.PI/6);
        var point3y = toy-headlen*Math.sin(angle+Math.PI/6);

        noFill();
        bezier(pos_1.x, pos_1.y, pointBx,  pointBy, point3x, point3y, pos_2.x, pos_2.y);
        stroke(myColor);
        strokeWeight(weight);
        line(pos_1.x, pos_1.y, pos_2.x, pos_2.y);

        fill(myColor);
        triangle(point1x, point1y, point2x, point2y, point3x, point3y);

Answers

Sign In or Register to comment.