5
\$\begingroup\$

From what I've read, people mostly use either quaternions or 3x3 matrices to represent 3D orientations, while plain vectors are used for angular velocity/momentum. Since we can use vectors to represent angular velocities, why can't we also use vectors to represent orientations? Are there any specific reasons or is it simply less convenient?

EDIT: Just to clarify, I mean using a 3D vector to represent a rotation around an arbitrary axis, with the magnitude being the rotation.

\$\endgroup\$
  • \$\begingroup\$ Can you work out how to use a vector to naturally represent a rotation? I can't, unless you mean a vector representing Euler angles, and there's plenty of information around on why those are both insufficient and inefficient. \$\endgroup\$ – Sean Middleditch Dec 19 '13 at 8:17
8
\$\begingroup\$

You are correct that a combined axis-angle representation like the one you describe has a stronger expressive power than many other systems because it can more conveniently store a rotation speed.

However, in practice, people actually use quaternions and 3×3 matrices to manipulate rotations a lot more than just represent them.

One typical operation is the combination of two rotations:

  • with quaternions, this is usually 16 multiplications.
  • with 3×3 matrices, this is usually 27 multiplications.
  • with an axis-angle representation, you don’t have much choice but to convert the transformation to something else, often a quaternion, requiring at least 16 multiplications plus a square root and three divisions (for normalisation) and at least two sine and two cosine operations.

Another operation is the transformation of a vector by a rotation:

  • with quaternions, this is usually 15 multiplications
  • with 3×3 matrices, this is usually 9 multiplications
  • with an axis-angle representation, this is at least 20 multiplications, a square root, three divisions, and two sine/cosine operations.

As you can see, the storage efficiency of an axis/angle representation is usually not worth it when you actually need to do things with the rotation. This article on Wikipedia has some more details.

\$\endgroup\$
  • \$\begingroup\$ Thanks. But I thought one can simply add vectors to combine rotations, since that's how (I think) it's done when combining angular forces, right? \$\endgroup\$ – slartibartfast Dec 19 '13 at 23:11
  • \$\begingroup\$ @slartibartfast I believe so, but there's a difference between "Add these two 3D angular velocities" and "rotate by this angular velocity for A seconds and then rotate by this angular velocity for B seconds". \$\endgroup\$ – user10968 Dec 20 '13 at 0:13
  • \$\begingroup\$ this is a little fallacious. You also need square root and sine to construct the quaternion. your "number of operations" is only true for application. the matrix as well need a sincos operation to build its components. \$\endgroup\$ – v.oddou Dec 20 '13 at 0:56
  • \$\begingroup\$ @v.oddou The one time creation cost is unimportant; often you create a quaternion once, and apply it to a hundred objects. This is my main argument (“people manipulate rotations rather than represent them”) and I don’t think it’s fallacious. Also, note that you usually do not need sine or cosine to construct a quaternion. \$\endgroup\$ – sam hocevar Dec 20 '13 at 9:42
2
\$\begingroup\$

The reason is because you cannot use a vector on its own to apply a rotation to anything. With a quaternion or matrix you can use mathematically defined operations to rotate something else. This is useful for transforming frames of reference, and is what the entire 3D pipeline is built upon.

However if only a direction is required, then yes a vector can be used. Vectors only represent a direction and scale (scale of the direction).

\$\endgroup\$
2
\$\begingroup\$

EDIT: Just to clarify, I mean using a 3D vector to represent a rotation around an arbitrary axis, with the magnitude being the rotation.

That is nearly what is saved in a quaternion only in a representation more useful to do calculations with it.

So basically, using a vector/angle pair directly:

  • is not very convenient for the machine and the programmer to maintain. Eg concatenating one vector/angle with another is very expensive and is probably done by converting both into matrix form, multiplying and converting it back. Quaternions are pretty good for calculations and allow easy slerps when interpolating between two angles.
  • is not very convenient when trying to figure out what a rotation looks like or when trying to enter one manually. Euler angles are the best for that.

Also storing the angle as magnitude is a bad idea because calculating the magnitude of a vector is VERY expensive. You should pay that extra float.

\$\endgroup\$
-3
\$\begingroup\$

Everybody is quite used to use vectors to represent orientations. notably this is classically the case in OpenGL light (directionals and spots) definitions, and camera directions. In DirectX also and in shaders also. we normally make sure the vector is normalized if the module is umimportant.

Many raytracers have a ray structure using v p; v u; which means a position and a unit vector representing the direction.

An alternative representation of direction is trhough the use of 2 angles, I use that systematically for first person shooter camera system. the mouse rotate lateraly and then vertically : 2 angles. This is enough and works very well.

\$\endgroup\$
  • 5
    \$\begingroup\$ No. Direction is not the same as orientation. \$\endgroup\$ – msell Dec 19 '13 at 7:34
  • 3
    \$\begingroup\$ "Red 1! What the heck are you doing?" "Red 2, I'm flying to the destination, over...?" "But you're flying upside down!!" "...But I'm still flying in the right direction, right...?" (In other words, msell's right) \$\endgroup\$ – Katana314 Dec 19 '13 at 15:29
  • \$\begingroup\$ I see. But the difference is not so obvious from plain English usage. This is a language convention. I would talk of a transformation to speak about a full fledged "orientation", which is what got me to answer assuming orientation=direction. I don't erase the answer so that it serves as a document for this language convention subtlety for future googlers. \$\endgroup\$ – v.oddou Dec 20 '13 at 1:01
  • \$\begingroup\$ Rotation can also be used for orientation. Transformation usually means orientation/rotation + translation when talking about objects. Scale is also often included, if it's an allowed operation in the context. \$\endgroup\$ – msell Dec 26 '13 at 7:25

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.