2
\$\begingroup\$

Unity uses quaternions for storing the rotation of rigid bodies, but vectors for the angular velocity. Why? I thought you'd use a quaternion instead of that vector also. I don't know much about quaternions and stuff, so please excuse me if this is a dumb question.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Is there something you think you'd want to do with an angular velocity that you cannot do with a Vector3? I'm struggling to think of any applications of angular velocity that would demand that it be in quaternion format... \$\endgroup\$
    – DMGregory
    Nov 23 at 18:39
  • \$\begingroup\$ @DMGregory the only reason I am aware of for using quaternions is to avoid the gimbal lock of rotational matrices. An explanation why that concern doesn't apply here would be cool to read. \$\endgroup\$
    – Vorac
    Nov 29 at 23:41
  • \$\begingroup\$ How would an angular velocity vector experience gimbal lock? It's not clear to me what that question would even mean in this context to be able to answer it. \$\endgroup\$
    – DMGregory
    Nov 29 at 23:43
2
\$\begingroup\$

Because not only is a Vector3 more compact, a quaternion can only represent a rotation of up to +/- 1 turn signed.

If you're storing angular velocity as "rotations per second" your object could be spinning at more than 1 rotation per second, a quaternion doesn't work for this (even if you chose a smaller time base you will reach a similar problem)

A Vector3 angular velocity can be longer than 1 unit of length to represent faster rotations than a quaternion could.

It's also much easier to work with when calculating friction, combining/adding angular velocity, multiplying by the frame delta time, clamping rotation speed (a simple vector length check), etc

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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