RenderMan & RISpec >> How to get first derivative value of a Bezier curve in C code.

by Ed » Fri, 19 Sep 2008 14:04:23 GMT

Hi, guys,
During the implementation of a Bezier curve, user want to get the
first derivative value at some position on the curve.
I know the Bezier equation, and using mathematic methods I can compute
the value easily.
But how did I put down the method into C code?

For example, I want to get the first derivative value at position t1
for a cubic Bezier curve (single float).
What I need to do is
1. Get the position value p1 at t1.
2. Get the position value p2 at (t1+0.000001).
3. Compute the derivative (p2-p1)/0.00001. Then normalize the value.
The value is the first derivative at position t1.

Right? Any problem? Precision is OK?

Thanks.


RenderMan & RISpec >> How to get first derivative value of a Bezier curve in C code.

by Rick LaMont » Tue, 23 Sep 2008 09:43:20 GMT



Can't you just do the math on paper and implement the equation?

A cubic Bezier curve is defined by four control points: p0, p1, p2 and p3.

B(t) = (1 - t)^3 * p0 +
3t * (1 - t)^2 * p1 +
3t^2 * (1 - t) * p2 +
t^3 * p3

So the first derivative is:

B'(t) = -3 * (1 - 2t + t^2) * p0 -
3t * (4 - 3t) * p1 +
3t * (2 - 3t) * p2 +
3t^2 * p3

You better double-check my math. I just did it off the top of my head.
The point is if you can do the code for a Bezier curve, it should be
easy to implement the first derivative also.


Rick LaMont
Dot C Software, Inc.
http://www.dotcsw.com/

Similar Threads

1. How to get first derivative value of a Bezier curve in C code.

Hi, guys,
During the implementation of a Bezier curve, user want to get the
first derivative value at some position on the curve.
I know the Bezier equation, and using mathematic methods I can compute
the value easily.
But how did I put down the method into C code?

For example, I want to get the first derivative value at position t1
for a cubic Bezier curve (single float).
What I need to do is
1. Get the position value p1 at t1.
2. Get the position value p2 at (t1+0.000001).
3. Compute the derivative (p2-p1)/0.00001. Then normalize the value.
The value is the first derivative at position t1.

Right? Any problem? Precision is OK?

Thanks.

2. Derivative of Bezier curve at endpoint

3. Quad Bezier curves to Cubic bezier curves.


Hi all,

   Hope this is th right group fro this question.

   I'm writing a java program that needs to convert some quadratic 
bezier curves to cubic bezier curves.  I hope this is possible... I'm a 
strong programmer but its been a while since if been in a math class so 
its not obvious to me how to do this.

   Can anyone point me in the right direction?  Also is it even possible 
to do this.

   Thanks.

   Glen


4. Getting smooth Bezier curves in SVG

5. bezier patch from boundary bezier curves

Hi All,

I'm working on an evenlope distorion ala Adobe Illustrator.
I was wondering: if the "envelope" is defined as 4 planar connected cubic
bezier curves (i.e. the 12 control points on the boundary of a bezier
patch), is there a way to obtain the other 4 control points making up a flat
bezier patch so that the distortion is reduced to a simple quadrilateral
into bezier-patch mapping?

TIA

Fernando Cacciola


6. How to raytrace bezier surface or bezier curve?

7. How to raytrace bezier surface or bezier curve?

One possible approach is to employ appropriate numerical method for
root finding, for example two-dimensional Newton iteration.  There are
other methods too, you may wish to check section 3.2 of "An Introducion
to Ray Tracing" book or some of papers discussing this problem
(starting from Kajiya's "Ray tracing parametric surfaces" from Siggraph
'82).

Alex.

8. How to find point on Bezier curve located on given distance from the start of curve