   Orientation matrix from a forward vector and a terrain-normal vector
  I'm trying to calculate an orientation for a vehicle with some specific requirements and information (that is unchangeable).  I have:1) A vector that's normal to the plane described by 3 rays cast down from 3 points of the vehicle to the terrain.2) A forward-facing vector for the vehicle (as reported by the main engine).Since the 3-point-raycast thing is actually a hack (with no connection to the rest of the engine) to keep the vehicle from clipping into obstacles outside of using an actual physics engine, there seems to be no guarantee that these vectors will be perpendicular.Unfortunately, my linear algebra is a bit lacking for non-basic tasks; so I was hoping to get some info here.  Thanks.   
  If the vectors are not perpendicular, there's no One True Answer. Taking the vehicle's vector for pitch, the terrain vector for roll, and assuming a right-handed coordinate system with the vehicle facing down the negative Z axis:Z = -FX = N x ZY = Z x XThis is essentially the same as the calculation of a "look-at matrix".   ;Quote:Original post by SneftelIf the vectors are not perpendicular, there's no One True Answer. Taking the vehicle's vector for pitch, the terrain vector for roll, and assuming a right-handed coordinate system with the vehicle facing down the negative Z axis:Z = -FX = N x ZY = Z x XThis is essentially the same as the calculation of a "look-at matrix".That's what I figured.  Looks like I'll just have to hack it up a bit more.  Too bad I'm not allowed to do it the right way.  Thanks for the response.   