Sign in to follow this  
dnaxx

Spline derivation

Recommended Posts

Hello! Source: http://www.bergen.org/AAST/projects/3DSMaxTutorial/mathematics.html That's the curve: and the formulas: . How do I get the x1', x2', y1', y2' derivations for the formulas? Thank you,

Share this post


Link to post
Share on other sites
Firstly, those formulas aren't entirely accurate. For example, when the interpolation variable t is 0, you'd expect to end up at one of the end points of the curve, while in fact you end up at the point (x1 + x2, y1 + y2)

As to your actual question, it seems a bit off... To get those derivatives, derive each function by the specific variable...
I think that what you're looking for is the derivative of the curve. ie. deriving with respect to t instead of x1

Share this post


Link to post
Share on other sites
If the OP needs the derivative (tangent) of the Bezier curve at t, it is P12 - P02 (the last DeCasteljua segment). More info here. The first and last control segments are tangents to the points P0 and P3, respectively (when evaluated, t=0, t=1).

See also section 2.5, parametric derivative which is a degree n-1 curve (n = 3: cubic => new curve is n = 2: quadratic, etc.). The first derivative curve is also called a hodograph.

Share this post


Link to post
Share on other sites
I would use the following curve equation:
P(t) = (1 - t)3P0 + 3t(1 - t)2P1 + 3t2(1 - t)P2 + t3P3

It uses actual control points, instead of two end points and their derivative vectors 3(P1 - P0) and 3(P3 - P2).

Share this post


Link to post
Share on other sites
Quote:
Original post by Zipster
I would use the following curve equation:
P(t) = (1 - t)3P0 + 3t(1 - t)2P1 + 3t2(1 - t)P2 + t3P3

It uses actual control points, instead of two end points and their derivative vectors 3(P1 - P0) and 3(P3 - P2).


That's a good point. The OP's diagram's tangent/derivative vectors are a bit short (the end of the vectors appear to be the inner geometric control points)...

The matrix evaluation form:


flt Mat4::evalSpline(flt a,flt controlPoints[4]) {
Vec4 s = *this ^ *(Vec4 *)controlPoints; // ^ = Mat4 transform Vec4
return ((s.x*a + s.y)*a + s.z)*a + s.w;
} // Mat4::evalSpline





allows evaluation of many different spline types (Bezier, b-spline, Hermite, Catmull-Rom, etc.).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this