Jump to content
  • Advertisement
Sign in to follow this  
Quak

derivative of bezier curve

This topic is 4409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm using de casteljau's algorithm to evaluate the point for a given u value on the curve. For this u value I also need the derivative. I know that after n-1 (where n is the degree of the curve) subdivisions I get two points which give me the tangent vector. My question is how this tangent vector is related to the derivative and how I can get the derivative. thanks, quak

Share this post


Link to post
Share on other sites
Advertisement
The Bezier curve is X(t) = sum_{i=0}^{n} B[n,i](t)*P, where P are the control points and B[n,i](t) are the Bernstein polynomials. The derivative of the Bernstein polynomials are dB[n,i](t)/dt = n*(B[n-1,i-1](t) - B[n-1,i](t)). This allows you to represent the curve derivative as X'(t) = n*sum_{i=0}^{n-1} B[n-1,i](t)*(P[i+1] - P).

Share this post


Link to post
Share on other sites
Yes, I know how to calculate the derivative with the Bernstein polynomials but I wonder how to calculate it with the de casteljau algorithm, as I already use it to evaluate points on the curve.

Share this post


Link to post
Share on other sites
Is this equal to subdividing the original curve n-1 times and then using the two remaining points to calculate the derivative like this: du = n*(P1-P0) where P1 and P0 are not the original control points but interpolated control points ?

Share this post


Link to post
Share on other sites
Yes, what you mention is equivalent. For example, de Casteljau method applied to a quadratic Bezier curve produces two values just before the final one, namely, P0' = (1-t)*P0+t*P1 and P1' = (1-t)*P1+t*P2. The derivative is 2*(P1'-P0'). When applied to a cubic Bezier curve, the two values just before the final one are P0' = (1-t)^2*P0+2*(1-t)*t*P1+t^2*P2 and P1' = (1-t)^2*P1+2*(1-t)*t*P2+t^3*P3. The derivative is 3*(P1'-P0').

Using my previous suggestion of applying de Casteljau to the degree n-1 curve with control points Q = n*(P[i+1] - P), you can apply de Casteljau to the P term to get P' just before the final term. Doing the same to the P[i+1] term, you get P'[i+1] just before the final term. The derivative is n*(P'[i+1]-P').

Share this post


Link to post
Share on other sites
Thanks a lot for your explanations, Wasting Time.

Now that I know how to get the derivatives of a curve, I'd just like to check if I got it right for surfaces as well:
Assuming I want to evaluate the partial derivative du at u0,v0 on the surface, I first evaluate all rail curves in v direction at v0 and then use the resulting intermediate points as the control points for a curve in u direction, which I evaluate at u0. I then use n*(P1'-P0') to calculate du, right?

Share this post


Link to post
Share on other sites
A rectangle patch is X(s,t) = sum_{i=0}^n sum_{j=0}^m B[n,i](s)*B[m,j](t)*P[j]. Set Q = sum_{j=0}^m B[m,j](t)*P[j], which is what I believe you are calling the "rail curves". Then X(s,t) = sum_{i=0}^n B[n,i](s)*Q, so you can use the curve result: dX/ds = sum_{i=0}^{n-1} B[n-1,i](s)*(n*(Q[i+1]-Q))). (That is, I believe the answer to your question is "yes".)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!