es

This section is divided into a number of subsections, links to which are:

Rotations

2D Rotations

Euler Theorem

Quaternions

Compositions

 

Parameterizing rotations and the orientation of frames is one of the important parts in 3D geometry. Describing and managing rotations in 3D space is a somewhat more difficult task, compared with the relative simplicity of rotations in the plane. We will explore two methods for dealing with rotation in two following subsections, Euler angles and quaternions.

There is a very important class of transformations known as orthogonal. They are generated by orthogonal matrices (or orthonormal matrices):

\[ {\bf Q}^{\mathrm T}{\bf Q} = {\bf Q}\,{\bf Q}^{\mathrm T} = {\bf I} , \qquad {\bf Q} \in \mathbb{R}^{n\times n} . \]
A particular case in three-dimensional real space ℝ³ of orthogonal matrices constitute so called orthogonal or simply rotation. The most general three-dimensional rotation matrix represents a counterclockwise rotation by an angle θ about a fixed axis that lies along the unit vector n, also usually denoted by \( \displaystyle \hat{\bf n} = (n_x , n_y , n_z ). \)

3D Rotations

Suppose that you are a pilot, such that the x-axis points to your left, the y-axis points ahead of you, and the z-axis points up. This is the coordinate frame. Then a rotation about the x-axis, denoted by φ, is called the pitch. A rotation about the y-axis, denoted by θ, is called roll. A rotation about the z-axis, denoted by ψ, is called yaw. Euler’s theorem states that any position in space can be expressed by composing three such rotations, for an appropriate choice of (φ, θ, ψ (see next section).

In 3D, rotation occurs about an axis rather than a point, with the term axis taking on its more commonplace meaning of a line about which something rotates. An axis of rotation does not necessarily have to be one of the three standard axes.

When Rotation occurs about a fixed point other than the origin, use the following three step approach:

  • Move fixed point to origin,
  • Rotate,
  • Move fixed point back.
Figure 5.2: https://gamemath.com/book/matrixtransforms.html#2d_rotation
Rotating about the x-axis in 3D.
Let's start with rotation about the abscissa (x-axis), as shown in the previous figure.
\begin{equation} \label{EqPlane.5} {\bf R}_x (\theta ) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos\theta & -\sin\theta \\ 0 & \sin\theta & \phantom{-}\cos\theta \end{bmatrix} . \end{equation}
Rotation about the ordinate is similar:
Figure 5.3: https://gamemath.com/book/matrixtransforms.html#2d_rotation
Rotating about the y-axis in 3D.
\begin{equation} \label{EqPlane.6} {\bf R}_y (\theta ) = \begin{bmatrix} \cos\theta & 0 & \sin\theta \\ 0 & 1 & 0 \\ -\sin\theta & 0 & \phantom{-}\cos\theta \end{bmatrix} . \end{equation}
And finally, rotation about the applicate is
Figure 5.4: https://gamemath.com/book/matrixtransforms.html#2d_rotation
Rotating about the z-axis in 3D.
\begin{equation} \label{EqPlane.7} {\bf R}_z (\theta ) = \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \phantom{-}\cos\theta & 0 \\ 0&0&1 \end{bmatrix} . \end{equation}
We can also rotate about an arbitrary axis in 3D, provided, of course, that the axis passes through the origin, since we are not considering translation at the moment. This is more complicated and less common than rotating about a cardinal axis. As before, we define θ to be the amount of rotation about the axis counterclockwise. The axis will be defined by a unit vector \( \displaystyle \hat{\bf n} = ( n_x , n_y , n_z ). \) The corresponding matrix of rotation is denoted as \( \displaystyle {\bf R} \left( \hat{\bf n}, \theta \right). \) Then the corresponding rotation of a vector v is defined by matrix multiplication:
\[ {\bf u} = {\bf R} \left( \hat{\bf n}, \theta \right) {\bf v} . \]
To derive the matrix \( \displaystyle {\bf R} \left( \hat{\bf n} , \theta \right) , \) we separate v into two vectors, v and v, which are parallel and perpendicular to \( \displaystyle \hat{\bf n} , \) respectively, such that \( \displaystyle {\bf v} = {\bf v}_{\|} + {\bf v}_{\perp} . \) Since v is parallel to n, it will not be affected by the rotation about n (namely, u = v). So all we need to do is compute u, and then we have u = v + u. To compute u, we construct the vectors v, v, and an intermediate vector w, as follows:
  • The vector v is the portion of v that is parallel to n:
    \[ {\bf v}_{\|} = \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} . \]
  • The vector u is the portion of v that is perpendicular to n: \( \displaystyle {\bf v} = {\bf v}_{\|} + {\bf v}_{\perp} . \)
  • The vector w is mutually perpendicular to v and v and has the same length as v. So
    \[ {\bf w} = \hat{\bf n} \times {\bf v}_{\perp} . \]
Figure 5.5: https://gamemath.com/book/matrixtransforms.html#2d_rotation
Rotating a vector about an arbitrary axis.
We are using v and w as our nre basis vectors for rotation. Using
\begin{align*} {\bf v}_{\|} &= \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} , \\ {\bf v}_{\perp} &= {\bf v} - \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} , \\ {\bf w} &= \hat{\bf n} \times {\bf v} , \\ {\bf u}_{\perp} &= \cos\theta \left( {\bf v} - {\bf v}_{\perp} \right) + \sin\theta \,{\bf w} , \end{align*}
we obtain
\begin{equation} \label{EqPlane.8} {\bf u} = {\bf u}_{\perp} + {\bf v}_{\|} . \end{equation}
Equation \eqref{EqPlane.8} allows us to rotate any arbitrary vector about any arbitrary axis, and corresponding matrix becomes
\[ {\bf R} \left( \hat{\bf n} , \theta \right) = \begin{bmatrix} n_x^2 \left( 1 - \cos\theta \right) + \cos\theta & n_x n_y \left( 1 - \cos\theta \right) - n_z \sin\theta & n_x n_z \left( 1 - \cos\theta \right) + n_y \sin\theta \\ n_x n_y \left( 1 - \cos\theta \right) + n_z \sin\theta & n_y^2 \left( 1 - \cos\theta \right) + \cos\theta & n_y n_z \left( 1 - \cos\theta \right) - n_x \sin\theta \\ n_x n_z \left( 1 - \cos\theta \right) - n_y \sin\theta & n_y n_z \left( 1 - \cos\theta \right) + n_x \sin\theta & n_z^2 \left( 1 - \cos\theta \right) + \cos\theta \end{bmatrix} . \]

  1. Verify directly that the following 3 × 3 matrices define rotation transformation along the line through the origin and the point (1, 1, 1).
    1. A rotation by π/6 (= 30°) is \( \displaystyle \quad \frac{1}{3} \begin{bmatrix} \left( 1 + \sqrt{3} \right) & 1 & \left( 1 - \sqrt{3} \right) \\ \left( 1 - \sqrt{3} \right) & \left( 1 + \sqrt{3} \right) & 1 \\ 1 & \left( 1 - \sqrt{3} \right) & \left( 1 + \sqrt{3} \right) \end{bmatrix} ; \)
    2. A rotation by π/3 (= 60°) is \( \displaystyle \quad \frac{1}{3} \begin{bmatrix} 2&2&-1 \\ -1&2&2 \\ 2&-1&2 \end{bmatrix} ; \)
    3. A rotation by π/2 (= 90°) is \( \displaystyle \quad \frac{1}{3} \begin{bmatrix} 1& \left( 1 + \sqrt{3} \right) & \left( 1 - \sqrt{3} \right) \\ \left( 1 - \sqrt{3} \right) & 1 & \left( 1 + \sqrt{3} \right) \\ \left( 1 + \sqrt{3} \right) & \left( 1 - \sqrt{3} \right) & 1 \end{bmatrix} ; \)
    4. A rotation by 2π/3 (= 120°) is \( \displaystyle \quad \begin{bmatrix} 0&1&0 \\ 0&0&1 \\ 1&0&0 \end{bmatrix} . \)
  2. For a given angle θ, you can write six matrices that define rotations along coordinate vectors i, −i, j, −j, k, and −k. Their inverse matrices give six more matrix expressions. Another twelve expressions are formed by putting −θ for θ. Break these twenty four matrix expressions into a separate lists so that the expressions in each list are necessarily equal but any two matrices from different lists are not equal in general. For example, R(i, θ) and (R(−j, θ))−1 are equal and so are in the same list.
  3. Find all 3 × 3 rotation matrices that are also diagonal.
  4. Show that a nonzero 3 × 3 matrix P is a rotation if and only if the rows of P have the same cross-product relation as i, j, k; for example, 1row × 2row = 3roe.

  1. Anton, Howard (2005), Elementary Linear Algebra (Applications Version) (9th ed.), Wiley International
  2. Dunn, F. and Parberry, I. (2002). 3D math primer for graphics and game development. Plano, Tex.: Wordware Pub.
  3. Foley, James D.; van Dam, Andries; Feiner, Steven K.; Hughes, John F. (1991), Computer Graphics: Principles and Practice (2nd ed.), Reading: Addison-Wesley, ISBN 0-201-12110-7
  4. Matrices and Linear Transformations
  5. Rogers, D.F., Adams, J. A., Mathematical Elements for Computer Graphics, McGraw-Hill Science/Engineering/Math, 1989.
  6. Watt, A., 3D Computer Graphics, Addison-Wesley; 3rd edition, 1999.