Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I understand the theory behind each but I was wondering if people could share their experiences in when one would use one over the other

For instance, if you were implementing a chase camera, a FPS-style mouse look or writing some kinematic routine, what would be the factors you consider to go with one type over the other and when might you need to convert from one form of representation to the other?

Are there certain things that only one system can do that the others can't? (eg smooth interpolation with quaternions)

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

I will quote John Carmack here:

You will eventually regret any use of Euler angles.

Source

In my experience, I have found this to be true. Euler angles are terrible for:

  • Relative orientation - parents to children, children to parents
  • Camera's - it's good to use a matrix, better to use a quaternion
  • Animation - matrices will have to be transformed to quaternions to be slerped anyway

However, if you want to store transformations as user-changeable text it's best to use Euler angles. Quaternions are difficult to wrap your brain around (4D space? What!) and a matrix looks like a mess of numbers to the average user.

But even here, you will probably regret their use eventually.

To answer your questions:

chase camera

Quaternion camera with Vec3 position. However, if it's quick and dirty, I'd use a matrix camera with a lookat from a normal to the target.

FPS-style mouse look

Quaternion camera with Vec3 position. Mostly because a quaternion camera doesn't have gimbal lock.

some kinematic routine

Quaternions for rotation, Vec3 for position. Quaternions can be lerped (fast) and slerped (quality). The only downside is that they will have to be converted to matrices before being uploaded to a shader, but the benefits outweigh the cost in this case.

share|improve this answer
    
+1 for the "In 3D always go with Matrices and Quaternions" but I'd add : in 2D go with Euler angles as there are no gimbal lock in 2 dimensions :-) (sure you can use matrices in 2D but well it usually feels a bit overkill if you don't do long animation chains) –  Valmond Jul 5 '12 at 12:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.