Public Group

# Vector Algebra

This topic is 3963 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello Friends. I’m writing a roller coaster simulator using C++ and OpenGL. I’ve got a cart (a cube really) moving through the track. As it stands the cart goes through the track ignoring physical rotation. My goal is to force the cube to rotate in accordance with the track. Assuming A(x,y,z) is the location of the cart and T[n] is an array of vertices for the tracks (with n being the total number of vertices for the track) how would I go about achieving this goal. Right now the cart is being animated through the points in T such that for each key frame A.x = T[frame].x A.y = T[frame].y A.z = T[frame].z Therefore the cart moves through the key frames (interpolation and physics will be added eventually) mechanically using the glutTimerFunc(). Now what I know is that somehow I have to use the cross product/dot product of A and T[frame+1] to get the angle from the location and the next point on the track array. Any help would be appreciated, and if this is not clear enough please let me know and I will try and explain it as much as I can.

1. 1
2. 2
Rutin
29
3. 3
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633648
• Total Posts
3013111
×