[ad_1]

What you are searching for known as “de Casteljau’s algorithm“

First, it’s essential to discover the phase and the parameter worth $t$ on the level that was clicked. Search “closest level on cubic Bézier spline” for algorithms to search out that.

Now you have got a phase with management factors ${ P_1, P_2, P_3, P_4 }$ and a parameter worth $0 < t < 1$ (if $t$ is strictly zero or one, then management level $P_1$ or $P_4$ respectively already cut up the spline on the clicked level), at which the Bézier phase passes by the clicked level $P_t$.

We can now type new factors by interpolating between the prevailing management factors by an element of $t$:

$$

P_5 = (1 – t) P_1 + t P_2

P_6 = (1 – t) P_2 + t P_3

P_7 = (1 – t) P_3 + t P_4

$$

and once more:

$$

P_8 = (1 – t) P_5 + t P_6

P_9 = (1 – t) P_6 + t P_7

$$

(If we wished, we might additionally discover $P_t = (1 – t) P_8 + t P_9$ this manner, however by this stage you in all probability already understand it)

Your two new Bézier segments are:

$$

{P_1, P_5, P_8, P_t}

{P_t, P_9, P_7, P_4}

$$

[ad_2]