"Fat" splines

Started by
1 comment, last by acid2 18 years, 8 months ago
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.
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
Advertisement
Hey,

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.

Cheers,
Ben
Thats brilliant, I got it working now :)
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]

This topic is closed to new replies.

Advertisement