Sign in to follow this  
hymerman

Mesaurement of curvature of Camull-Rom spline segment

Recommended Posts

Hi, I've just been learning about curves and have started using Catmull-Rom splines in my game. I'd like to get a measurement of curvature of the spline (or at various points along the spline), but can't find anything through google that can help me. While I was reading, I was clicking random things in Wikipedia (as you do) and stumbled across pages for curvature and osculating circles. I just about understand the maths, but I wouldn't be able to apply that to Catmull-Rom splines and then convert it into C++. Is there any example code out there that will calculate curvature, or at least something that will help a little? Along the same lines but a little simpler, is there any example code out there for calculating the tangent to a Catmull-Rom spline segment at a given t? Currently I'm just approximating by taking the difference between positions either side of t, but that just feels nasty!

Share this post


Link to post
Share on other sites
yeah, take the derivative of the catmul rom equation, that will give you 'tangent' at a point. The second derivative will give you the... 'acceleration', but it's not continuous (it can flip around).

Share this post


Link to post
Share on other sites
Thanks - I figured that if I took the second derivative using the slightly dodgy 'difference across a point' method I'd get some measure of curvature, but probably not the actual curvature, the measurement I can invert to get the radius of the osculating circle at that point.

What's the 'proper' (mathematical) way to take the derivative and second derivative of a Catmull-Rom spline segment? My differentiation skills are a little rusty, and I'm sure this is something someone has tackled before (and hopefully codified in C++!).

Share this post


Link to post
Share on other sites
should be quite easy. the catmull rom is a polynomial, with (t) as a parameter. Simple derive the polynomial for (t).


q(t) = 0.5 *(
(2 * P1) +
(-P0 + P2) * t +
(2*P0 - 5*P1 + 4*P2 - P3) * t2 +
(-P0 + 3*P1- 3*P2 + P3) * t3
)




so :


q'(t) = 0.5 * (
(2 * P1) + (-P0 + P2) +
2 * (2*P0 - 5*P1 + 4*P2 - P3) * t +
3 * (-P0 + 3*P1- 3*P2 + P3) * t2
)



I think... bit rusty too.

Share this post


Link to post
Share on other sites
Quote:
Original post by oliii

q'(t) = 0.5 * (
(2 * P1) + (-P0 + P2) +
2 * (2*P0 - 5*P1 + 4*P2 - P3) * t +
3 * (-P0 + 3*P1- 3*P2 + P3) * t2
)



Fixed [smile]

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