Followers 0

# Roll Snap For Rollercoaster Simulation

## 1 post in this topic

I'm working on a rollercoaster simulation, I have a path of points so that means I have the tangents for each point.
I'm calculating the binormals and normals as explained here: [url="http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html"]http://www.cs.cmu.ed...sst2camera.html[/url]

The problem with that is the normals start to roll when going up and turning, so when the path comes back down, the normals aren't facing directly up like you'd expect. What I want to do is lock the rolling of the track so for example, if you tried to create a loop, the path would start to twist when getting near to the top so there's never any roll in the track.

So I've found a paper that I think solves this but I'm having trouble understanding what they mean at the "roll snap" section.

[url="https://dip.felk.cvut.cz/browse/pdfcache/hykovter_2010bach.pdf"]https://dip.felk.cvu...er_2010bach.pdf[/url]

It first off starts by saying "Using a dot product, we calculate the angle between the vector pointing straight up ((0, 1, 0)?) and a vector being the up vector that we want to straighten."

That itself confuses me because if i dot a normal of (0,1,0) and (0,1,0), that's going to give me a value of 1. That is not an angle i should be applying to the normal because in that situation the normal is correct and doesn't need to be corrected.

Tried to explain as best I could. If not, here's an image that explains what I want to happen.

[img]https://dl.dropbox.com/u/99765/fortblox/r34324.png[/img]
If I have a track like this that has roll, I want to remove all roll by rotating the normal around the tangent.

The reason why I need to do this is so the user can define the roll of each node instead of the track rolling on its own when creating the track. Edited by laylay
0

##### Share on other sites
I seem to have fixed it.

This is the part I think I was getting wrong.
"Using dot product, we calculate the angle between the vector pointing straight up and the vector that we want to straighten"

I translated that to
float angle = normal.Dot(Vector3f(0.0f, 1.0f, 0.0f));

When it should be
float angle = normal.Dot(tangent.Cross(Vector3f(0.0f, 1.0f, 0.0f)));
0

## Create an account

Register a new account