Jump to content
  • Advertisement
Sign in to follow this  

"Fat" splines

This topic is 5191 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've just got catmull-rom splines working, but I'd now like to use them as the format of my tracks in a racing game I'm making. I can get all the points, etc - but how can I make the splines "fatter." I basically need a way of finding 2 points that lie perpendicular to a point - if that makes sense. If anyone needs a diagram for explanation, I can happily provide you with one.

Share this post

Link to post
Share on other sites

If you know a point on the curve and a tangent vector to the curve at that point, then finding the perpendicualr points you're after is just basic trig.

If you take the cross-product of tangent and up vectors at any point, you will get a perpendicualr vector. (If your track is flat, then this up vector would be [0,1,0] or alternatively you could use some other vector representing camber).

Your perpendicular points lie along this vector, and so finding them is just a matter of normalising and scaling by the desired width.

I did have a diagram that explained this, but my ftp was being arsey. Should be simple enough though :

1) find tangent,
2) cross product with up vector,
3) scale resulting vector by desired width.

Only thing with this naieve (sp?) approach is that for tight bends there is no guarentee that the perpendicular points will form a smooth curve without intersecting. Again a diagram would show this, but i can't upload from this PC.

Also just to warn you; i've no real knowledge of catmull-rom splines - this is just the most obvious approach that struck me at the time.


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!