Sign in to follow this  
Crazy Chicken

3D Rotation question

Recommended Posts

I have noticed that there is two main approches to rotation in 3D. The first approach uses 3 floating point variables (yaw, pitch, roll) to keep track of the current angle of rotation around each axis. When an object is rotated the floats are incremented accordingly. Therefore a new rotation matrix or quaternion can be created using the yaw, pitch, roll values. The second approach on the other hand does not keep track of any values but instead only creates a rotation quaterion based on the amount the object is rotated by every update. This quaternion is then multiplyed by a global rotation quaterion which keeps track of the total rotation. I was wonderering which approach is better? Any comments will be helpful. Thx Luke

Share this post


Link to post
Share on other sites
Well, both have their advantages. The main problem with Euler angles (y/p/r) is Gimbal lock - two of the angles sort of cancel each other out - resulting in no rotation. Quaternions aren't affected by this. However, they can be quite tricky - one look at the number of posts in the Maths & Physics forum about them will tell you this :)

Share this post


Link to post
Share on other sites
Euler type angles suit FPS's
Your regular FPS games like "quake" ensure that the vertical axis on the map is almost always vertical on the screen. Eg a vertical pole in the game is always going to point directly toward the top of your screen. This is easily achieved using 2-rotation euler angles, but it has the problem that when you are looking very up or very down it is very difficult to try and point the screen (crosshair) at objects.

Quaternion or axis-angle methods are what 3d space-fighter type games probably use, as well as good flight simulators. You can use them for FPS type games if you want, they're just a little more tricky. However, no matter what direction you are looking it is easy to point the screen (crosshair) at objects.

More generally, euler angles are sort-of special case, wheras quaternions are general-purpose.
Euler uses trig functions to convert to a matrix, while quaternions use multiplication, addition and subtraction, making them possibly a little faster during rendering, but this is probably an area where speed matters little, unless you are doing many thousands of rotations per frame.
Quaternions are a lot slower to manipulate, though, but this probably doesn't matter either.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this