Archived

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

Rotations and vectors

This topic is 5241 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 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 on other sites
The direction that the velocity is crossed with is a vector in real world coordiantes that represents the front facing of the ship.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• Forum Statistics

• Total Topics
632652
• Total Posts
3007651
• Who's Online (See full list)

There are no registered users currently online

×