Duplicate quadratic Bézier curve with new start point?

378 Views Asked by At

I have Bézier curve as shown by the wikipedia gif here: enter image description here

I would like to create a new curve that is a segment of the old one. For example, in this gif (from the same article):

enter image description here

.. if I wanted B to be the starting point of the new curve, but for the curve to follow the same path, how could I find the new control point?

I can see that the answer is very straightforward and easily solvable, but my mind still hasn't caught up with the logic behind the equation for the quadratic Bézier curve:

enter image description here

so I'm having trouble thinking it out. I would greatly appreciate any hints/advice that would help push me in the right direction.

2

There are 2 best solutions below

5
On

Suppose you know $Q_0$:

Note that since $Q_0$ is on the line $\overline{P_0P_1}$, we can write $Q_0=(1-k)P_0+kP_1$ for some $k$, $0\leq k\leq1$, which has to be determined. To have the same curve, you also require $Q_1=(1-k)P_1+kP_2$.

Then, the original bezier curve is traced out by varying $t$ from $0$ to $1$. You can get the segment by varying $t$ from $k$ to $1$ to trace out the curve from $B$ to $P_2$.

More than likely, you don't know $Q_0$, but only $B$.

Since the bezier curve traces out the line $$ C(t) = (1-t)^2P_0+2t(1-t)P_1+t^2P_2, $$ by solving $B=(1-t)^2P_0+2t(1-t)P_1+t^2P_2$ for $t$, you get the beginning of the range for which $t$ will vary. This must have a solution, since $B$ is on the curve $C(t)$. I have called this $k$ above.

0
On

Generically, this process is known as De Casteljau subdivision: it turns out that the process of (recursively) evaluating the curve at a given point leads to new sets of control points representing the curves on either side of that point. In your case, in the process of evaluating $B=B(t)$ from $P_0$, $P_1$ and $P_2$ we build the following structure:

  • $Q_0 = (1-t) P_0 + t P_1$
  • $Q_1 = (1-t) P_1 + t P_2$
  • $B = (1-t) Q_0 + tQ_1$

It then turns out that the two pieces of the curve to either side of $B$ can be represented by the curves with control points $(P_0, Q_0, B)$ and $(B, Q_1, P_2)$ (each over the interval $(0..1)$, of course), respectively. Proving this is a grind through the algebra, but it's a fairly instructive one - I definitely recommend trying it for yourself.