user: How do I use Quaternion Mode in Blender? Include parameters, examples, warnings and best practices.

assistant: In this mode, rotations are also defined by four values (X, Y, Z and W).
X, Y and Z also define an axis, and W an angle, but it does it quite differently from axis-angle.
The important thing here is the relation between all four values.

To describe it in an intuitive way, let’s take the effect of the X coordinate:
what it does is to rotate the element around the X axis up to 180 degrees.
The same goes for Y and Z. The effect of W is to avoid those rotations and leave
the element with zero rotation. The final orientation is a combination of
these four effects.

As the relation between components is what defines the final orientation, multiplying or dividing all four numbers
by a constant value will yield the very same rotation.

This mode is ideal for interpolating between **any** pair of orientations.
It doesn’t suffer from gimbal lock or any interpolation undesired effect.
The only drawback is that you cannot interpolate between two orientations
that are at a distance greater than 180°, as the animation will take
the shortest path between them. Thus to animate a revolving element
you must set up many intermediate keyframes, 180° from each other at most.

The *Gimbal* gizmo in this mode is equivalent to the *Local* one, and doesn’t have any special meaning.

The animation curves in this mode are not intuitive, so they are also difficult to understand and edit.

### More about Quaternions

This section is not really useful for 3D artists, but it can be suitable for the curious or the scientist.

Quaternions are a number system extending the complex numbers. They represent a four component vector, whose
components are called, in Blender, X, Y, Z and W.
When rotating interactively in quaternion mode, the so called norm (length) of the quaternion will remain constant.
By definition, the norm of a quaternion equals 1.0 (that’s a **normalized** quaternion). When you select
the quaternion mode in Blender, the XYZW components describe a normalized quaternion.

However, if one of the quaternion components is locked during the interactive transformation using the proper
lock button, the norm will not remain unchanged, as that blocked component will not be able to adjust itself to
keep the unit norm.

The rotation components of a quaternion keep a tight relation with those of axis-angle. To find a correspondence,
first of all we must deal with the normalized version of the quaternion, that is, one whose norm equals 1.0.
To normalize a quaternion, just divide each one of its components by its norm.
As we have seen before, dividing all four values by the same number gives the same orientation.

Once we have calculated the components of the normalized quaternion, the relation with the axis-angle components
is as follows:

- X, Y and Z mean exactly the same as in axis-angle: they just define an axis around which the rotation takes place.
- W can be used to retrieve the actual rotation around the defined angle.
  The following formula applies (provided that the *quaternion is normalized*):
  \(W = \cos(\frac{a}{2})\), where *a* is actually the rotation angle we are looking for. That is:
  \(a = 2 \arccos{W}\).