• Advertisement

# Roll Snap For Rollercoaster Simulation

This topic is 1904 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

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: http://www.cs.cmu.ed...sst2camera.html

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.

https://dip.felk.cvu...er_2010bach.pdf

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.

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

#### Share this post

##### Share on other sites
Advertisement
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)));

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### Popular Tags

• Advertisement
• ### Popular Now

• 10
• 9
• 12
• 10
• 12
• Advertisement