利用者:Pepribal/Ref/Appendices/Rotation

提供: wiki
< 利用者:Pepribal‎ | Ref
2014年12月11日 (木) 16:16時点におけるwiki>Pepribalによる版 (More about quaternions)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Rotation modes

Blender lets you define rotations in several ways. Each one of them has a series of advantages and drawbacks; there is no best rotation mode, as each one is suitable for specific cases.

In all of these modes, positive angle values mean counter clockwise rotation direction, while negative values define clockwise rotation.

Though you can rotate elements using the global or local transform orientations, these axes are not suitable to define rotations, because the effect of each of the three axes cannot be isolated from the other two.

Take, for instance, any 3 values for X, Y and Z rotation. Perform each one of these using global or local axes. Depending on the order in which you perform these, you will end up with different final orientations. So we need proper rotation coordinate systems.

Euler rotation modes

The axes system used for performing Euler rotations is the so called Euler gimbal. A gimbal is a particular set of 3 axes. The special thing about this is that the axes have a hierarchical relationship between them: one of the axes is at the top of the hierarchy, and has one of the other two axes as its child; at the same time, this child axis is the parent of the remaining axis, the one at the very bottom of the hierarchy.

Which axis is on top, which one in the middle and which at the bottom, depends on the particular Euler gimbal: there are 6 types, as there are 6 possible combinations: XYZ, XZY, YXZ, YZX, ZXY and ZYX Euler rotation modes. These modes are named using the letters of the axes in order, starting from the axis at the bottom of the hierarchy, and finishing with the one on top.

The main problem of these systems comes when they lose their relative perpendicularity. And that happens when the axis in the middle rotates, causing the axis at the bottom rotate with it. It keeps getting worse when this bottom axis approaches 90° (or equivalent angles). In that case, it will remain aligned with the axis on top of the hierarchy. In that very moment we have just lost one axis of rotation. This can cause very weird interpolations when animating. This particular loss of axis is known as the gimbal lock.

The actual configuration of the gimbal axes can be seen using the 3D manipulators with Gimbal transformation orientation selected, provided that the rotation mode selected is an Euler mode.

One advantage of this mode is that animation curves are easy to understand and edit. However, special attention must be done when the middle axis reaches values close to 90° (or equivalents).

Axis Angle rotation mode

This mode lets us define an axis (X, Y, Z) and a rotation angle (W), in radians, around that axis (1 radian equals 180°/Π).

To define an angle in relation to the Π value, we can write things like pi/2 (90°), 2*pi (360°), etc.

If we define the rotation using interactive rotations, the values of X, Y and Z will not exceed 1.0 in absolute value, and W will be comprised between 0.0 and 2xΠ (360°).

If you wish to define rotations over 2xΠ, that is, if you wish to define multiple revolutions, you will have to edit the W value directly, but as soon as you perform an interactive rotation, that value will be adjusted again. Same thing goes for axis values.

This system is suitable for elements revolving around a fixed axis. The problem might come when animating (interpolating) both components at the same time: axis and angle. The resulting effect might not be as expected, though axis-angle system is free from gimbal lock.

The Gimbal transformation orientation in this mode shows a set of axes in which the Z axis goes along the defined rotation axis, pointing towards the direction defined by the (X, Y, Z) point.

However, the animation curves in this mode are not intuitive at all, so they are difficult to understand and edit.

Quaternion rotation mode

In this mode, rotations are also defined by 4 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 any pair of orientations. It doesn't suffer from gimbal lock or any interpolation undesired effect. The only drawback is that you cannot interpolate more than 180°, as the animation will take the shortest path from one orientation to the other: to animate a revolving element you must set up many intermediate keyframes.

The Gimbal transformation orientation in this mode is equivalent to Local, and so doesn't have any special meaning.

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

More about quaternions

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

Quaternions are a number system extending the complex numbers. They have 4 components, called, in Blender, X, Y, Z and W.

When rotating interactively in quaternion mode, the so called norm of the quaternion will remain constant. The norm of a quaternion q is defined mathematically as:

<math>\lVert q \rVert = \sqrt{X^2 + Y^2 + Z^2 + W^2}</math>

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 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 which 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: <math>W = \cos (a/2)</math>, where a is actually the rotation angle we are looking for.

Other considerations

In axis-angle and quaternion modes we can lock rotations in interactive modes in a per component basis, instead of doing it by axis. To do so we can activate this locking ability using either the 4L button in the Transform panel in the Properties sidebar of the 3D View editor, or the Rotation tick box in the Transform Locks panel in the object context of the Properties editor. Any of those can be used to make a fourth lock appear, enabling then the component locking.

Regarding rotation animations, all the keyframes must be defined in the same rotation mode, which must be the selected rotation mode for the object.