Hacker News new | ask | show | jobs
by nox101 849 days ago
GA seems great! But ...

> and modern formats like Khronos' glTF use quaternions for all their rotation needs. Fantastic for animations, and generally considered worth the cost of the unavoidable conversions to and from matrices.

Quaternions are bad for animation. Animate a clock going from 9am on Monday to 6pm on Friday. Euler angles this might be expressed as from 0 degrees to 1620 degrees. With Quaternions, nope. This can't be expressed in gLTF. It can be in Unreal an Unity, both of which default to use Eular for animation. In gLTF you're required to bake it into smaller turns, all less than 180 degrees.

4 comments

For specifying animations, you should work in the quaternion lie algebra, not in the group as you suggest. There you can represent 1620 degrees without any problem. Furthermore, in the quaternion Lie algebra (pure imaginary quaternions), and only in that space, you can take an arbitrary rotation key, multiply all 3 of its values with 10 and get 10 times that rotation without change in axis.

If you rotate around just one axis, the Lie algebra feels just like Euler angles .. in fact its exactly the same thing, but if you rotate around more than one .. it keeps working intuitively and usably - Euler angles absolutely do not.

Also, the use case for quaternions depends on how many times you will be applying the same rotation. If it's a few or dozens of times then maybe not the most efficient. If it's million or billions then you are going to want to use quaternions.

This is mainly due to the cost of converting to and from the rotation vector.

i.e. keep it in vector form if you're combining them a lot, convert to polar form when you want to work with angles
In exponentiated form, a GA rotor can be specified to spin as many times as you like, rotating continuously in the plane by the angle you specify. Think of rotations in the complex plane.
Most animations have more than 2 keyframes per week
There are lots of examples of a spinning clock showing time passing quickly. Lots of other things spin as well.

There's a reason Unity and Unreal (and Maya, and Blender, and 3DSMax) all use euler angles as their default animation representation.

Unity uses quats in its object transforms?
But not in it's animation data, at least not by default

You key euler angles, it lerps euler angles for animation values, it then generates a quaternion the given the current value of the euler angles. Same for Unreal AFAIK

Where in the docs does it say that? Euler angle lerps, in the general case (eg none of the starts or ends are 0), look like complete shit.

You need the log quat representation. Exp( Tlog(q1/q0) ) q0

> When interpolating between two rotations, the interpolation can either be performed on the Quaternion values or on the Euler Angles values.

from: https://docs.unity3d.com/2023.3/Documentation/Manual/animedi...

The default is Euler values

From that page: "When Euler Angles interpolation is used, Unity internally bakes the curves into the Quaternion representation used internally. This is similar to what happens when importing animation into Unity from external programs"