Archived

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

Rotations and vectors

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

I''m Trying to get a spaceship model I designed to follow its velcity vector, but I can''t get it to work. using OpenGL''s glRotated() command using a rotation vector determind by Velocity X Ship''s starting direction. and the angle determined by acos(Velocity * Start). % is cross product * is dot product .Unit() returns Unit Vector. RotDir = Velocity%Direction; Rotation = -acos(Velocity.Unit()*Direction.Unit()); glRotated(Rotation,RotDir.GetI(),RotDir.GetJ(),RotDir.GetK());

Share this post


Link to post
Share on other sites
One thought is that it looks like you''re trying to do cumulative rotation, whereas glRotate() is absolute. That is, your angle/axis just tells you how far your ship rotated in that frame, but glRotate() requires an angle/axis that represents the ship''s orientation in relation to the world axes. That may be your problem.

I do this all with quaternions, but that may be a lot of math for you to get into. You can also do cumulative rotations with matrices, but there are a few pitfalls involved.

''3D Math Primer'' goes over most of this stuff, and you can find this info in most good graphics books.

Share this post


Link to post
Share on other sites