science forum beginner
Joined: 22 Jun 2006
|Posted: Thu Jun 22, 2006 8:58 am Post subject:
Bezier track path with inversions
(Note: This was also posted to comp.graphics.algorithms, but I felt I
should go ahead and try posting this here as well)
There's a roller coaster simulator out for Windows/Mac called No Limits
(http://www.nolimitscoaster.de/ (The site is in English and German)
that uses bezier curves to define the track. For banking, you set the
angle of banking in degrees for each control point.
I'm writing a program to convert tracks made with this program into
POV-Ray (http://www.povray.org) scenes. But I'm running into a huge
problem with inversions.
The problem stems from how banking is calculated in No Limits. You can
create a vertical loop with only two control points - one pointing up,
the other pointing down. Of course, at both of those points, the track
is right-side up, so the banking is 0. Of course, a smooth track will
typically have more control points than that. Anything before the
vertical will have very little banking, but once you go past the
vertical, banking has to be around 180 to get the track to be upside
So now it comes down to how to implement this.
The simplest implementation would just take the cross product of the
vector <0,1,0> and the current direction of travel to find an up
vector, and then rotate that around the current direction of travel. I
then interpolate between the resulting up vectors on each control point
to find intermediate up vectors. This works in the second method of
constructing a loop as described above, but runs into the problem of
vertical track not working.
To accomodate for vertical track, No Limits allows you to specify that
a given banking angle is "relative" to the previous. Using that
information (Plus a hint from someone on the POV-Ray newsgroups) I
tried another method. First, I convert all banking angles into
relative banking, then I start with an initial up vector, and I step
along the bezier. At each step, I cross the current up vector with
the current direction of travel to get the "right" vector, then cross
that again with the current direction of travel. This finds a new up
that compensates for a change in vertical slope, which I then rotate
around the current direction of travel to find the appropriate banking.
I then use that up vector during my next step.
This SORT of works for the first method of making a loop described
above. The problem is, if the track is changing heading while on a
vertical slope or banked, the resulting up vector ends up being a bit
banked. Eventually, all track ends up being banked when it shouldn't
Does anyone have any idea how I could do this? The No Limits website
has a demo version that lets you use the editor so you can see exactly
how tracks are designed.
If anyone can help at all, it would be greatly appreciated, and I may
even put your name (if you'd like) in the program credits when I am
(Remove the TRIMBRAKES to reply)