title: How can I extend bezier curve?
body: <p>I am using this piece of code to cauculate a cubic bezier curve for s in [0, 1]. I want to extend the curve base on its geometric continuity. I tried just set s other than [0, 1] but the result is not correct. Is there actually a possible algorithm for calculating bezier point ?</p>
  
  <p>pb, pbh, peh, pe are vectors of cubic bezier's control points.</p>
  
  <pre><code>*pq = pb*powf(1-s, 3) + pbh*(3*s*(powf(1-s, 2))) + peh*(3*powf(s, 2)*(1-s)) + pe*powf(s,3);
  </code></pre>
  
  <p><a href="http://imageshack.us/photo/my-images/217/37013437.jpg/" rel="nofollow">http://imageshack.us/photo/my-images/217/37013437.jpg/</a></p>
  
  <p>This is the image I got. The white curve is what I want to get. There are three white Bezier curves linked one to another. The center one is the curve based on my code. The extended curve (the whole white curve which approximately twice as long as the center one) is what I wanted. However, if I just build a Bezier curve with my code with s in range [-0.5, 1.5], I will get the green one, which does not even pass the two original control points.</p>
  
  <p>For the handles of green line I used the following code, which also, works fine with s in [0, 1]. p123 is the new left handle in green, and p234 is the new right one.</p>
  
  <pre><code>p12 = (pbh-pb)*s+pb;
  p23 = (peh-pbh)*s+pbh;
  p34 = (pe-peh)*s+peh;
  
  p123 = (p23-p12)*s+p12;
  p234 = (p34-p23)*s+p23;
  </code></pre>
  
  <p>Thanks in advance</p>