Skip to main content
GameDev.net gamedev.net
🔒 Locked

3D Splines

Started by Agemaniac Apr 25, 2004 at 3:57 PM 7 replies 800+ views
Original Post
Agemaniac
Agemaniac
Hi, im trying to implement a 3D curve, that give a set off control points interpolate all the points (passing throught all of them). So i think 3D Splines is the answer. My question is, what kind of spline should i use. Bezier, natural , B-Spline(i think not). I read something about Bezier curves and figure out that they just pass throught the first and last points in a group of four. So, if i need to pass through all the points i should calculate 2 middle points for each pair. Does anyone knows a link, article, piece of code or something like this that i can read or interpret?.. thanks.
JOL
JOL
Looking into my litterature it seems that what you are looking for is a Catmull-Rom spline aka Overhauser spline.
The basic idea is to calculate the controlpoints of a ordinary spline by making them point in the direction of the line connecting the adjacent points.
The representation of a Catmull-Rom spline is:

| -1 3 -3 1 ||P_(i-3)|
Q_i(t) = 1/2*T*| 2 -5 4 -1 ||P_(i-2)|
| -1 0 1 0 ||P_(i-1)|
| 0 2 0 0 ||P_(i) |

P_(i-2) means P index i-2

(according to Computer Graphics Principles and practice second edition) -recomendable

Maybe this wasn't that helpful but you might want to look search for Catmull-rom and Overhausen

EDIT:
The book also reffered to this paper...
author: Barry, P. and R. Goldmine "A Recursive Evaluation Algorithm for a Class of Catmull-Rom Splines" SIGGRAPH 88 199-204


[edited by - JOL on April 25, 2004 5:39:48 PM]
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I'm looking for work
Agemaniac
Agemaniac
Hi, thanks for the reply, it seens that you are right. I have just some questions. I have read something about the spline u have mentioned and got a little confused.

Given a 4 control points, does the formula calculate the spline between all of then or just the first two are first last?

If i have 5 points, for example, how can i use this formula to calculate the points? I read an article that said: to calculate the spline between two points use the formula (that u said) and using a 0
wolverine
wolverine
Well, the formula works for groups of 4''s. In a group of 4 points (numbered 0 to 3), the curve touches the points nr1 and nr2.

So if you have, say 6 points (numbered from 0 to 5), you''ll need
3 segments curves:

0 1 2 3 -> defines 1st curve segment
1 2 3 4 -> defines 2nd curve segment
2 3 4 5 -> defines 3rd curve segment

where the curve touches points 1 2 3 4

and where there''s geometric continuity between the segments.
i. e. the math garantees that the 1st segement is connected to the 2nd, the 2nd connected to the 3rd... and so on .
Agemaniac
Agemaniac
Hi, thanks. My spline is working now. i got just some problems when trying to walk through a spline at constant speed. The problem is that when i reach a critical part of a spline, for example, a curve section, the distance between 2 consecutives points(points calculated given a t and t+step) is less than two consecutives points of the straight part. Is there a way to solve this problem?
SpaceDude
SpaceDude
http://www.gamedev.net/community/forums/topic.asp?topic_id=221094
Agemaniac
Agemaniac
hum..it seens that i cant you the Catmul Spline or any of it to directly get a constant velocity.. right.? so i thing im in the wrong way
SpaceDude
SpaceDude
No, you can''t get constant velocity for any of those curves... well not directly anyway, you can do it iteritively though...
JOL
JOL
Just a thought about the constant speed. You could probably fake it with a simple adjusting algorithm, changing the t value dynamically. eg between to timesteps, make sure that the traveled distance is the same (or with a small variance).
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I'm looking for work

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.