   orienting objects in 3D space
  This has been bugging me for a while. Recently I tried to make a motorcycle game with 3D environments. Obviously there had to be hills otherwise it would be a pretty boring game. My problem came when the bike was going up or down one of these hills, and the terrain beneath it was on an angle of somekind.I knew the position of some point on the motorcycle (say the back tire), and I knew the position of all other important points relative to that point. The trouble was that, when the bike was on a hill, I could not find a way to efficiently determine the angle that the bike should be rotated so that both tires were touching the ground. I had a function to determine the height of the ground at any (x, y) position. If I rotated the cycle so that its front tire was at a certain height based on its horizontal position, the front tire wouldnt touch the ground. I know this makes absolutly no sense, so there is a picture of what I''m talking about at http://www.angelfire.com/me5/incarnaterw/bike1.jpgI''m probably overlooking something really simple here, so if anyone knows a fast way to get that front tire on the ground, please tell me 
  The angle of the triangle at the downhill wheel is alpha = atan(h/a), so a good spot x, to take the altitude for the uphill wheel,cos(alpha) = x / a, so x = a * cos(alpha);to find the error in this approximation, take the altitude at this new point x, and compare it to a * sin(alpha) which would be your new h.Not perfect, but much better. 