   Vector Algebra
  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 frameA.x = T[frame].xA.y = T[frame].yA.z = T[frame].zTherefore 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.