Jump to content
  • Advertisement
Sign in to follow this  

How to calculate the length of a somewhat well defined curve?

This topic is 4616 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

I'm trying to make my spaceship corner in a nice curve, but my math is a bit hazy in one area. The curve has two endpoints, I know the starting and ending angles for both and the coordinates for both. What equation should I use to find its length? I'm wondering as to how the "level of curvature" is handled. You can assume it's constant throughout the curve. Or am I going to need some more variables to define that as well? (I notice Photoshop has the normal pull-points for curve corners... that makes the issue harder, hmm?)

Share this post

Link to post
Share on other sites
Well, assuming the curvature is constant, I would think you can just calculate the circumfrence(C = 2πr) of the circle that it would form if it went 360o and divide by the difference between starting and ending angles. Hope that helps.


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Step 1) Approximate the curve with 2 line segments.

Step 2) Subdivide the curve into two intervals corresponding to the two line segments

Step 3) Repeat step 1

If you have an analytic formula for the curve, this procedure will yield (a close but not exact) riemann sum as the number of line segments increases, that it will converge to the length of the curve. This should solve your problem.

Share this post

Link to post
Share on other sites
If you have a parametric curve, like
u(t) = {x(t),y(t),z(t)}
and you know which values of the parameter correspond to the initial and final point, let them be t0 and t1, then the length between those points is:
Integral[from t0 to t1, sqrt(x2(t)+y2(t)+z2(t)), dt]

As for the curvature...
Find the first and second derivative of the curve. (Notice that if 't' represents time, these will be the vectors of velocity and acceleration of the object)
The vectors {t, n, b), where:
t(t) = u'/|u'|
n(t) = b X t
b(t) = u' X u"/|u' X u"|

are a right-handed orthogonal base of unit vectors, where t(t) is the tangent vector at the point u(t), n is the vector of curvature at the point u(t), and b(t) is the vector of torsion.

If you apply the following world matrix to the object...

[ n.x b.x t.x x(t) ]
[ n.y b.y t.y y(t) ]
[ n.z b.z t.z z(t) ]
[ 0 0 0 1 ]

the spaceship will orientate perfectly with respect to the curve at any of its points.

fixed bug with "

[Edited by - someusername on February 28, 2006 4:51:06 PM]

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!