Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!