• Advertisement

Archived

This topic is now archived and is closed to further replies.

orienting objects in 3D space

This topic is 5133 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

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.jpg I''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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

  • Advertisement