MarkCC has a post about quaternions and the fact that they can be used for rotation, so I thought I'd chime in with exactly how they represent rotations.

A 2D rotation by an angle θ can be represented by the complex number on the unit circle

cos θ + i sin θ

Then multiplying complex numbers is the same as multiplying rotations.

A 3D rotation by an angle θ about a line defined by a unit vector (b,c,d) can be represented by the quaternion on the unit hypersphere

cos θ/2 + sin θ/2(bi + cj + dk)

Then multiplying quaternions is the same as multiplying rotations.

But why is it θ/2 instead of θ?

Well, in 3D, in some sense you have to rotate through 720° to really get back where you started from. There's a nice animation of the Dirac Belt Trick that shows how you can remove a 720° twist from a belt without moving the ends. However, you can't remove a 360° twist. The quaternions q and -q are different but both represent the same 3D rotation.

Andrew Hanson has some demonstration programs that show how quaternions do rotations. These accompany his book Visualizing Quaternions.


More like this

Jack Kuipers' "Quaternions and Rotation Sequences" is also good. It's applications based, very readable and diagrammatic.

I don't think it mentions the belt trick though.

By Greg Bakker (not verified) on 08 Aug 2006 #permalink

I use quaternions in my Monte Carlo simulations of real molecular systems. For what I do they are superior to rotation matrices because of their numerical stability.

For the things I do it is necessary to have rotoinversion (improper rotation) as well. I do this by carrying along a flag in my code which tells me if this is a proper or improper rotation.

I remember asking my mate (Theoretical Physicist) about quaternions when I first looked into them and he said "What do you want with them? Noone uses them anymore ...". Heh.

Quaternions are fine, but I find that anytime you're working in SO(3) or SE(3) it involves a lot of scribbling and crumpled up paper, no matter the framework. :P

Nice article. I stumbled upon this post while looking for 3-D rotation calculations in PHP. No PHP code but a very clear explanation. So thank you. I'll make this site one of my regulars...