Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
    
Sorry, meant B to be the starting point. –  mowwwalker Mar 15 '13 at 8:39
    
@Walkerneo In order to keep the same shaple of the curve, you need the same control points. What you need to do to get a segment of the curve it to change the domain of $t$. In my description above, I describe how to get an appropriate domain for $t$ for your problem. –  Daryl Mar 15 '13 at 10:05
    
@Daryl In fact, that's just not true - you can actually define new control points that will give you either segment of the curve, and those control points fall naturally out of the process for evaluating the curve at the given point. You don't need to keep track of domains of $t$ at all. –  Steven Stadnicki Mar 16 '13 at 1:10
    
@StevenStadnicki I didn't say it was the only way, but it is one method. –  Daryl Mar 16 '13 at 4:25
    
@Daryl -- I'd say that your use of the word "need" (twice) suggests that the solution you proposed is the only one. Anyway, whatever you meant to imply, restricting the domain is not the only approach. In fact, it's not even the usual approach. Most people would calculate new control points using the de Casteljau algorithm, as StevenS suggested. –  bubba Mar 17 '13 at 8:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.