Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The remarkable thing about quaternions is that you can describe rotation around any arbitrary axis! Try doing that with real rotation matrices and you will bump into a major problem:

https://en.wikipedia.org/wiki/Gimbal_lock

Because matrix multiplication is not commutative, you can't easily compose a matrix representing rotation around an arbitrary axis from "component rotation matrices".

With quaternions/clifford algebras, you can say "here's the vector I want to rotate about and here's this is how much I want to rotate", and it just magically works.



Not quite...

Gimbal lock is no problem of rotation matrices but of euler angles. Just look up the wikipedia page you posted: "The problem of gimbal lock appears when one uses Euler angles in applied mathematics"

You can represent any (any!) rotation with rotation matrices.

Quaternions are neither commutative. Fortunately you don't need commutativity to build up arbitrary rotations.


Thanks, I realize now that the non-commutativity I was noticing is more a property of SO(3), which can be seen both in quaternion and matrix representations of rotations.


The non-commutativity of rotations can also be seen directly: rotating something 90 degrees about the x then the y axis is not the same as the y then the x.


I was just doing this earlier with my arms


> The remarkable thing about quaternions is that you can describe rotation around any arbitrary axis! Try doing that with real rotation matrices and you will bump into a major problem

https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matri...


I understand you can represent any rotation with matrices, but it's very awkward, and when you compose rotations, you quickly lose information about the resulting axis of rotation.


The information is still there. The axis of rotation is the eigenvector with eigenvalue 1. (That vector doesn't move when you apply the rotation)


Okay let me rephrase: the axis of rotation becomes relatively obfuscated!

I guess it doesn't matter if you're doing everything on the computer, but it's pretty cool that with quarternions you can immediately see the composite rotation's axis and angle without any extra work!


I find that many articles explaining how to describe the orientation of a rigid body rotated along an axis by an angle in a confusing manner.

Normally in 3d space you will have to construct quaternions for rotations along yaw, pitch and roll, and then take their product to get the quaternion of the orientation of the rigid body.

That is, when using quaternions to describe orientations,we are actually describing the rotations done to bring the body from its default orientation to its present orientation.


> Normally in 3d space you will have to construct quaternions for rotations along yaw, pitch and roll, and then take their product to get the quaternion of the orientation of the rigid body

Is this not just using Euler angles via quaternions? If I understand correctly, tracking rotation via yaw, pitch, and roll will still run into issues of gimbal lock because it's the same parameterization just using quaternions.


how is that an example of using quaternion for something else than rotations?




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: