es

The Wolfram Mathematic notebook which contains the code that produces all the Mathematica output in this web page may be downloaded at this link. Caution: This notebook will evaluate, cell-by-cell, sequentially, from top to bottom. However, due to re-use of variable names in later evaluations, once subsequent code is evaluated prior code may not render properly. Returning to and re-evaluating the first Clear[ ] expression above the expression no longer working and evaluating from that point through to the expression solves this problem.

$Post := If[MatrixQ[#1], MatrixForm[#1], #1] & (* outputs matricies in MatrixForm*)
Remove[ "Global`*"] // Quiet (* remove all variables *)

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

Rotations

2D Rotations

Euler Rotation Theorem

3D Rotations via Shearing

Quaternions

Compositions

Cayley Decomposition

 

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.

3D Rotations

Suppose that you are a pilot, such that the x-axis points to your right, 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).

Three dimensional orthogonal matrices have simple defining properties: each column is a unit length vector which is perpendicular to the others, and the third column is the cross product of the first two. (Rows satisfy the same properties.) The first two properties are those of orthogonality, and can be summarized as QTQ = I, the identity matrix; the last makes the orthogonality special, and can be stated as det(Q) = +1. Orthogonality alone implies that the determinant must be either +1 or –1, with the latter indicating the presence of a reflection in the matrix. A 3×3 orthogonal matrix with negative determinant can be converted to a pure rotation by factoring out a −I.

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

arx = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {-0.5, -0.5}}]}]; ary = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {1, 0}}]}]; arz = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {0, 1}}]}]; ary2 = Graphics[{Blue, Dashed, Thickness[0.007], Arrowheads[0.07], Arrow[{{0, 0}, {Sqrt[3]/2, 1/2}}]}]; arz2 = Graphics[{Blue, Dashed, Thickness[0.007], Arrowheads[0.07], Arrow[{{0, 0}, {-1/2, Sqrt[3]/2}}]}]; txt = Graphics[{Black, Text[Style[Subscript[x, 1], FontSize -> 18, Bold], {-0.38, -0.6}], Text[Style["x = ", FontSize -> 18, Bold], {-0.5, -0.6}], Text[Style["O", FontSize -> 18, Bold], {0, -0.15}], Text[Style["y", FontSize -> 18, Bold], {1, 0.15}], Text[Style[Subscript[y, 1], FontSize -> 18, Bold], {0.78, 0.6}], Text[Style[Subscript[z, 1], FontSize -> 18, Bold], {-0.4, 0.9}], Text[Style["z", FontSize -> 18, Bold], {0.15, 1}]}]; txt2 = Graphics[{Black, Text[Style[\[Phi], FontSize -> 18, Bold], {0.4, 0.1}], Text[Style[\[Phi], FontSize -> 18, Bold], {-0.1, 0.4}]}]; Show[arx, ary, arz, ary2, arz2, txt, txt2]
Figure 1: 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 (\phi ) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos\phi & -\sin\phi \\ 0 & \sin\phi & \phantom{-}\cos\phi \end{bmatrix} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos\phi & \sin\phi \\ 0 & -\sin\hi & \phantom{-}\cos\phi \end{pmatrix}^{\mathrm T} , \end{equation}
where the latter matrix corresponds to rotation of row vectors. Actually, rotation matrices used to rotate rows or columns are just transposed of the other (marked with letter "T"). Matrices operate on vectors by multiplicaion either from left (on column vectors) or from right (on row vectors). Note that we write matrices in brackets when they operate on column vectors upon multiplying from right. On the other hand, matrices written in parentheses are used to operate on row vectors.

Rotation about the ordinate has a similar matrix:

arx = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {-0.5, -0.5}}]}]; ary = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {1, 0}}]}]; arz = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {0, 1}}]}]; arx2 = Graphics[{Blue, Dashed, Thickness[0.007], Arrowheads[0.07], Arrow[{{0, 0}, {-0.25, -Sqrt[3]/2}}]}]; arz2 = Graphics[{Blue, Dashed, Thickness[0.007], Arrowheads[0.07], Arrow[{{0, 0}, {-1/2, Sqrt[3]/2}}]}]; txt = Graphics[{Black, Text[Style[Subscript[x, 2], FontSize -> 18, Bold], {-0.14, -0.82}], Text[Style["x", FontSize -> 18, Bold], {-0.5, -0.6}], Text[Style["O", FontSize -> 18, Bold], {0.1, -0.15}], Text[Style["y = ", FontSize -> 18, Bold], {0.9, 0.15}], Text[Style[Subscript[y, 2], FontSize -> 18, Bold], {1.036, 0.15}], Text[Style[Subscript[z, 2], FontSize -> 18, Bold], {-0.4, 0.9}], Text[Style["z", FontSize -> 18, Bold], {0.15, 1}]}]; txt2 = Graphics[{Black, Text[Style[\[Theta], FontSize -> 18, Bold], {-0.1, 0.4}], Text[Style[\[Theta], FontSize -> 18, Bold], {-0.23, -0.4}]}]; Show[arx, ary, arz, arx2, arz2, txt, txt2]
Figure 2: 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} = \begin{pmatrix} \cos\theta & 0 & -\sin\theta \\ 0 & 1 & 0 \\ \sin\theta & 0 & \phantom{-}\cos\theta \end{pmatrix}^{\mathrm T} . \end{equation}
And finally, rotation about the applicate is
arx = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {-0.5, -0.5}}]}]; ary = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {1, 0}}]}]; arz = Graphics[{Black, Thickness[0.01], Arrowheads[0.1], Arrow[{{0, 0}, {0, 1}}]}]; arx2 = Graphics[{Blue, Dashed, Thickness[0.007], Arrowheads[0.07], Arrow[{{0, 0}, {-0.25, -Sqrt[3]/2}}]}]; ary2 = Graphics[{Blue, Dashed, Thickness[0.007], Arrowheads[0.07], Arrow[{{0, 0}, {Sqrt[3]/2, 1/2}}]}]; txt = Graphics[{Black, Text[Style[Subscript[x, 3], FontSize -> 18, Bold], {-0.14, -0.82}], Text[Style["x", FontSize -> 18, Bold], {-0.5, -0.6}], Text[Style["O", FontSize -> 18, Bold], {0.1, -0.15}], Text[Style["y", FontSize -> 18, Bold], {1, 0.15}], Text[Style[Subscript[y, 3], FontSize -> 18, Bold], {0.78, 0.6}], Text[Style[Subscript[z, 3], FontSize -> 18, Bold], {0.27, 1}], Text[Style["z = ", FontSize -> 18, Bold], {0.15, 1}]}]; txt2 = Graphics[{Black, Text[Style[\[Psi], FontSize -> 18, Bold], {0.4, 0.1}], Text[Style[\[Psi], FontSize -> 18, Bold], {-0.23, -0.4}]}]; Show[arx, ary, arz, arx2, ary2, txt, txt2]
Figure 3: Rotating about the z-axis in 3D.
\begin{equation} \label{EqPlane.7} {\bf R}_z (\psi ) = \begin{bmatrix} \cos\psi & -\sin\psi & 0 \\ \sin\psi & \phantom{-}\cos\psi & 0 \\ 0&0&1 \end{bmatrix} = \begin{pmatrix} \cos\psi & \sin\psi & 0 \\ -\sin\psi & \phantom{-}\cos\psi & 0 \\ 0&0&1 \end{pmatrix}^{\mathrm T} . \end{equation}

The three angles ϕ, θ, ψ give a parametrization of the group of rotations, SO(3). Another parametrization will be considered in the fllowing section.

Arbitrary Axis of Rotations

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 general 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 ) \) along the axis. The corresponding matrix of rotation is denoted as \( \displaystyle {\bf R} \left( \hat{\bf n}, \theta \right). \) Then the rotation of a vector v is defined by matrix multiplication:
\begin{equation} \label{EqRot.4} {\bf u} = {\bf R} \left( \hat{\bf n}, \theta \right) {\bf v} \quad\mbox{or} \quad {\bf u}^{\mathrm T} = {\bf v}^{\mathrm T} {\bf R} \left( \hat{\bf n}, \theta \right)^{\mathrm T} , \end{equation}

where v and u are column vectors from ℝ3×1. Be aware that in many applications a rotation matrix is used as an operator acting from left on column vectors as well as an operator acting from right on row vectors. the corresponding matrices are transposed of each other. When a matrix is multiplied from left, we write it in brackets. On the other hand, we embrace matrix in parentheses when it acts on row vectors from right.

ell = ParametricPlot[{Cos[2*t + 1], 1.2* Sin[2*t]}, {t, 0, Pi}, Axes -> False, PlotStyle -> {Blue, Thickness[0.01]}]; nn = Graphics[{Black, Line[{{-4, -4}, {0.5, 0.5}}]}]; n = Graphics[{Blue, Arrowheads[0.1], Thickness[0.02], Arrow[{{-4, -4}, {-2, -2}}]}]; arr = Graphics[{Blue, Arrowheads[0.07], Arrow[{{-0.39, -0.21}, {-0.3, -0.34}}]}]; ll1 = Graphics[{Black, Dashed, Thick, Line[{{-4, -4}, {-0.9, 1.24}}]}]; ll2 = Graphics[{Black, Dashed, Thick, Line[{{-4, -4}, {0.9, -1.2}}]}]; txt = Graphics[{Black, Text[Style["n", FontSize -> 18, Bold], {-2.0, -1.5}]}]; Show[nn, n, ell, arr, ll1, ll2, txt]
Figure 4: Rotation about an arbitrary axis in 3D.

Determination of rotation trough matrix multiplication \eqref{EqRot.4} is not computationally efficient because a rotation is specified by four parameters (angle θ and three components of axis of rotation) but 3-by-3 matrix R(n, θ) has nine entries. A more efficient algorithm is discussed in a special section on quaternions. In this section, we present two approaches for determination of rotation matrix (Mathematica has a dedicated command RotationMatrix), both based on observation that a rotation in 3D is actally a two-dimensional when plane of rotation is known.

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 new basis vectors for rotation. Using
\begin{align*} {\bf v}_{\|} &= \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} \qquad (\mbox{center of rotation}), \\ {\bf v}_{\perp} &= {\bf v} - \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} \qquad (\mbox{radius of rotation is lenth of } |{\bf v}_{\perp} |), \\ {\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
\[ \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} . \]
   
Example 1: For our first example, consider the following situation: We wish to rotate the point P(3,5,7), through the angle θ = π/6, about the line L, which passes through the origin and the point Q(–2, 4, 1). The corresponding vector v = OP and unit vector n along line L are \[ {\bf v} = (3, 5, 7) \qquad \mbox{and} \qquad \hat{\bf n} = \frac{1}{\sqrt{21}} \left( -2, 4, 1 \right) . \] We decompose vector v as \[ {\bf v} = {\bf v}_{\perp} + {\bf v}_{\|} , \qquad {\bf v}_{\|} = \sqrt{21}\,\hat{\bf n} = \left( -2, 4, 1 \right). \]
v = {3, 5, 7}; n = (1/Sqrt[21])*{-2, 4, 1}; Simplify[v . n]
Sqrt[21]
Hence, the center of rotation is situated at (−2, 4, 1). The radius of rotation is 62 because \[ {\bf v}_{\perp} = {\bf v} - {\bf v}_{\|} = (3, 5, 7) - (-2, 4, 1) = (5, 1, 6) . \] Vector v is perpendicular to the axis of rotation and gos through the given point P(3, 5, 7). We normalize it \[ {\bf u} = \frac{{\bf v}_{\perp}}{\| {\bf v}_{\perp} \|} = \frac{1}{\sqrt{62}} \left( 5, 1, 6 \right) \] and choose another orthogonal unit vector \[ {\bf w} = {\bf u} \times {\bf n} = \frac{1}{\sqrt{1302}} \left( -23, -17, 22 \right) . \]
u = (1/Sqrt[62])*{5, 1, 6}; w = Cross[u, n]
{-(23/Sqrt[1302]), -(17/Sqrt[1302]), 11 Sqrt[2/651]}
We check whether w has unit length:
Norm[w]
1
In the plane of the circle of rotation, u and w are acting as the positive x- and y-axis unit vectors, where our point P(3, 5, 7) is always positioned at the coordinates (1,0) in the (u, w)-coordinate system. Now the circle of rotation has the vector parametric equation given by \[ {\bf v}_{\|} + \sqrt{62}\,\cos\left( \theta \right) {\bf u} + \sqrt{62}\,\sin\left( \theta \right) {\bf w} . \] For θ = &pi//6, we have \[ \left( -2, 4, 1 \right) + \frac{\sqrt{3}}{2} \left( 5, 1, 6 \right) + \frac{1}{2} \,\frac{1}{\sqrt{21}} \left( -23, -17, 22 \right) . \]
ell = ParametricPlot3D[{{-2, 4, 1} + {5, 1, 6}* Cos[t] + {-23, -17, 22}*Sin[t]/Sqrt[21], PlotStyle -> Thickness[0.03]}, {t, 0, 2*Pi}]
   ■
End of Example 1

 

General Observation


Let T denote the desired rotation by angle θ with respect to a line through the origin in direction u₃ in the counterclockwise direction. Then for any vectors u₁, u₂, u₃ and any three real numbers 𝑎, b, c, we have
\[ T\left( a{\bf u}_1 + b{\bf u}_2 + c{\bf u}_3 \right) = a\,T\left( {\bf u}_1 \right) + b\,T\left( {\bf u}_2 \right) + c\,{\bf u}_3 . \]
Now we choose a basis β = [u₁, u₂, u₃] of unit vectors so that u₃ = u₁ × u₂ is a cross product of two other vectors. Then
\[ T\left( a{\bf u}_1 + b{\bf u}_2 + c{\bf u}_3 \right) = \left( a\,\cos\theta -b\,\sin\theta \right) {\bf u}_1 + \left( a\,\sin\theta + b\,\cos\theta \right) {\bf u}_1 + c\,{\bf u}_3 . \]
Thus, in terms of the ordered basis β, the matrix of this transformation becomes
\[ [\![ T ]\!]_{\beta} = \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0&0&1 \end{bmatrix} . \]
If you want to obtain the matrix of the transformation in terms of the standard ordered basis ε = [e₁, e₂, e₃] = [i, j, k], you need to solve the matrix equation
\[ [\![ T ]\!]_{\beta} = \begin{bmatrix} {\bf u}_1 & {\bf u}_2 & {\bf u} \end{bmatrix}^{-1} [\![ T ]\!]_{\varepsilon} \begin{bmatrix} {\bf u}_1 & {\bf u}_2 & {\bf u} \end{bmatrix} . \]
Recall that this formula follows from the following diagram:
\[ \begin{array}{ccc} \mathbb{R}^3 & \stackrel{[\![ T ]\!]_{\varepsilon}}{\rightarrow} & \mathbb{R}^3 \\ q\,\downarrow && \downarrow\, q \\ \mathbb{R}^3 & \stackrel{[\![ T ]\!]_{\beta}}{\rightarrow} & \mathbb{R}^3 \end{array} . \]
The map q is accomplished by a multiplication on the left by [u>₁, u₂, u₃], where basis column vectors u>₁, u₂, u₃ are expressed through standard basis ε. Then
\[ [\![ T ]\!]_{\varepsilon} = q\,[\![ T ]\!]_{\beta} q^{-1} = \begin{bmatrix} {\bf u}_1 & {\bf u}_2 & {\bf u}_3 \end{bmatrix} \,[\![ T ]\!]_{\beta} \begin{bmatrix} {\bf u}_1 & {\bf u}_2 & {\bf u}_3 \end{bmatrix}^{-1} . \]
Suppose the unit vector u>₃ about which the counterclockwise rotation takes place is u>₃ = (𝑎, <>b, c). We also assume that c > 0 to ensure that ordered basis [u>₁, u₂, u₃] is a right-handed rthonormal.

Two first vectors, u>₁ and u₂ must be orthogonal to u>₃ and have unit magnitudes;. Since they are arbitrary except these two properties, we can choose them wisely. So we set

\[ {\bf u}_2 = \frac{1}{\sqrt{a^2 + b^2}} \left( a, -b, 0 \right) \perp {\bf u}_3 . \]
Another orthnormal vector is determined by
\[ {\bf u}_1 = {\bf u}_2 \times {\bf u}_3 = \frac{1}{\sqrt{a^2 + b^2}} \left( -ac, -bc, a^2 + b^2 \right) . \]
Finally, we build the rotation matrix:
\[ \begin{bmatrix} \frac{-ac}{\sqrt{a^2 + b^2}} & \frac{b}{\sqrt{a^2 + b^2}} & a \\ \frac{-bc}{\sqrt{a^2 + b^2}} & \frac{-a}{\sqrt{a^2 + b^2}} & b \\ \sqrt{a^2 + b^2} &0&c \end{bmatrix} \, \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0&0&1 \end{bmatrix} \, \begin{bmatrix} \frac{-ac}{\sqrt{a^2 + b^2}} & \frac{b}{\sqrt{a^2 + b^2}} & a \\ \frac{-bc}{\sqrt{a^2 + b^2}} & \frac{-a}{\sqrt{a^2 + b^2}} & b \\ \sqrt{a^2 + b^2} &0&c \end{bmatrix}^{-1} \]
Using Mathematica, we simplify the product of three matrices
\[ \begin{bmatrix} a^2 + \left( 1 - a^2 \right) \cos\theta & ab \left( 1 - \cos\theta \right) - c\sin\theta & ac \left( 1 - \cos\theta \right) + b \sin\theta \\ ab \left( 1 - \cos\theta \right) + c \sin\theta & b^2 + \left( 1 - b^2 \right) \cos\theta & bc \left( 1 - \cos\theta \right) - a \sin\theta \\ ac \left( 1 - \cos\theta \right) -b \sin\theta & bc \left( 1- \cos\theta \right) + a \sin\theta & c^2 + \left( 1 - c^2 \right) \cos\theta \end{bmatrix} \]
With this, it is clear how to rotate clockwise about the unit vector, (𝑎, <>b, c). Just rotate counter clockwise through an angle of −θ.    
Example 3: Let us consider a vector (2, 3, −1) that spans line L of rotation. Suppose we want to determine a rotation matrix R(θ) for say θ = π/6 radians (counterclockwise).

The first step is to find a positive orthonormal basis of ℝ³, β = [v₁, v₂, u], where \( \displaystyle \quad {\bf u} = \left( 1/\sqrt{14} \right) \left( 2, 3, -1 \right) \quad \) is a unit vector spanning L and v₁, v₂ are an orthonormal basis for the orthogonal plane L. ‘Positive’ means det[v₁|v₂|u] = 1. We start by ‘trial and error to determine one vector \( \displaystyle \quad {\bf v}_1 = \left( 1/\sqrt{5} \right) \left( 1, 0, 2 \right) \quad \) from L. Another vector we determine by taking cros product \[ {\bf v}_2 = {\bf v}_1 \times {\bf u} = \frac{1}{\sqrt{70}} \left( -6, 5, 3 \right) . \]

u = (1/Sqrt[14])*{2, 3, -1}; v1 = (1/Sqrt[5])*{1, 0, 2}; Cross[v1, u]
{-3 Sqrt[2/35], Sqrt[5/14], 3/Sqrt[70]}
We check the determinant of these three vectors: \[ \det \left[ {\bf v}_1 , {\bf v}_2 , {\bf u} \right] = - 1 < 0 . \]
Det[{{1, 0, 2}, {-3 Sqrt[2/35], Sqrt[5/14], 3/Sqrt[70]}, {2, 3, -1}}]
-Sqrt[70]
So we take the basis as β = [v₂, v₁, u]

Second step: computing the action of rotation matrix R(θ = π/6] on the basis vectors. Since u is a vector on the axis, it is fixed by R: R u = u. In the plane L, R acts exactly like the counterclockwise rotation by π/6 radians in ℝ², so we know what R does to an orthonormal basis. We obtain: \begin{align*} {\bf R}\,{\bf v}_2 &= {\bf v}_2 \cos \left( \frac{\pi}{6} \right) - {\bf v}_1 \sin \left( \frac{\pi}{6} \right) = \frac{\sqrt{3}}{2}\,{\bf v}_2 - \frac{1}{2}\,{\bf v}_1 , \\ {\bf R}\,{\bf v}_1 &= {\bf v}_2 \sin \left( \frac{\pi}{6} \right) + {\bf v}_1 \cos \left( \frac{\pi}{6} \right) = \frac{1}{2}\,{\bf v}_2 + \frac{\sqrt{3}}{2}\,{\bf v}_1 , \\ {\bf R}\,{\bf u} &= {\bf u} . \end{align*} This means that the matrix of R in the ‘adapted’ basis β is: \[ [\![{\bf R}]\!]_{\beta} = \begin{bmatrix} \sqrt{3}/2 & -1/2 & 0 \\ 1/2 & \sqrt{3}/2 & 0 \\ 0&0&1 \end{bmatrix} . \] Third step. Now use the change of basis formula. We have: \[ {\bf R} = {\bf P}\,[\![{\bf R}]\!]_{\beta} {\bf P}^{-1} \] where P is the matrix of column vectors of the basis β = [v₂, v₁, u] \[ {\bf P} = \begin{bmatrix} -\frac{6}{\sqrt{70}} & \frac{1}{\sqrt{5}} & \frac{2}{\sqrt{14}} \\ \frac{5}{\sqrt{70}} & 0 & \frac{3}{\sqrt{14}} \\ \frac{3}{\sqrt{70}} & \frac{2}{\sqrt{5}} & - \frac{1}{\sqrt{14}} \end{bmatrix} . \] We check with Mathematica that such constracted matrix R is orthogonal, RTR = I, the identity matrix:

   ■
End of Example 3
   
Example 4: Viviani's curve, also known as Viviani's window, is a figure eight shaped space curve named after the Italian mathematician Vincenzo Viviani(1622-1703). A Viviani's curve is obtained by intersection of a sphere and a cylinder that is tangent to the sphere and passes through two poles (a diameter) of the sphere: \[ x^2 y^2 + z^2 = R^2 , \qquad x^2 y^2 = R\, x . \] Parametric definition of Viviani curve: \begin{align*} x &= R\,\cos^2 u , \\ y &= R\,\cos u\,\sin u , \\ z & = R\,\sin u , \qquad u \in [0, 2\pi ] . \end{align*} Another paramentization is obtained by setting 2𝑎 = R, t = 2θ: \begin{align*} x - a &= a\,\cos t , \\ y &= a\,\sin t , \\ z&= 2a\,\sin\frac{t}{2} . \end{align*}
Rotating of Viviani's curve.
   ■
End of Example 4

Reflections

Reflection (also called mirroring) is a transformation that “flips” the object about a line (in 2D) or a plane (in 3D). In general, it is an isometry with a hyperplane as a set of fixed points. Reflection can be accomplished by applying a scale factor of −1:
\[ S({\bf a}, -1)\,{\bf v} = ,{\bf v} -2\,\frac{{\bf v} \bullet {\bf a}}{{\bf a} \bullet {\bf a}}\,{\bf a} , \]
where va denotes the dot product of v with a. Note that the second term in the above equation is just twice the vector projection of v onto a. The orthogonal matrix corresponding to the above reflection is the matrix
\[ S({\bf a}, -1) = {\bf I} - 2\,\frac{{\bf a},{\bf a}^{\mathrm T}}{{\bf a}^{\mathrm T} {\bf a}} , \]
where I denotes the n-by-n identity matrix and aT is the transpose of column vector a ∈ ℝn×1. Its entries are
\[ \delta_{i,j} - 2\,\frac{a_i a_j}{\| {\bf a} \|^2} \]
where δi,j is the Kronecker delta. The formula for the reflection in the affine hyperplane va = c not through the origin is
\[ S({\bf a}, -1)\,{\bf v} = ,{\bf v} -2\,\frac{{\bf v} \bullet {\bf a} - {\bf c}}{{\bf a} \bullet {\bf a}}\,{\bf a} . \]

In case when nomal vector a in formulas above has a unit length, we can write the reflection matrix in three-dimensional space as

\begin{equation} \label{EqReflection.1} {\bf S}\left( \hat{\bf n}, -1 \right) = {\bf I} - 2 \, {\bf P} = {\bf I} - 2 \begin{bmatrix} n_x^2 & n_x n_y & n_x n_z \\ n_x n_y & n_y^2 & n_y n_z \\ n_x n_z & n_y n_z & n_z^2 \end{bmatrix} , \end{equation}
where I is the identity mtrix and \( \displaystyle \quad \hat{\bf n} = ( n_x , n_y , n_z ) \quad \) is a unit vec

Out of many linear transformations in ℝ³, only translations, rotations, uniform scale, and reflections preserve the magnitudes of angles. However, the latter may reverse the direction of the angle. The following example illustrates the general formula for reflection matrix.    

Example 2: Find the orthogonal matrix (in the standard basis) that implements reflection on the plane with equation: \[ 2\,x + 3\,y - z = 0. \]

Solution: The orthogonal line L is spanned by the unit vector: \[ \hat{\bf n} = \frac{1}{\sqrt{14}} \left( 2, 3, -1 \right) . \] Any vector v ∈ ℝ³ can be written as the sum of its orthogonal projections on L and on the given plane L: \[ {\bf v} = \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} + {\bf w} , \qquad {\bf w} = {\bf v} - \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} \in L^{\perp} . \] The reflection T flips n (so Tn = −n) and fixes every wL (that is, Tw = w). By linearity of T, we have \begin{align*} T{\bf v} &= \left( {\bf v} \bullet \hat{\bf n} \right) T\hat{\bf n} + T\,{\bf w} \\ &= \left( {\bf v} \bullet \hat{\bf n} \right) \left( -\hat{\bf n} \right) + {\bf w} \\ &= - \left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} + \left( {\bf v} - \left( {\bf v} \bullet \hat{\bf n} \right) \right) \\ &= {\bf v} -2\left( {\bf v} \bullet \hat{\bf n} \right) \hat{\bf n} . \end{align*} Incidentally, this calculation gives a general formula for the reflection on a plane with unit normal n.) In the present case, this reads: \[ T{\bf v} = {\bf v} - \frac{2}{14}\,\left\langle {\bf v}, (2, 3, -1) \right\rangle \left( 2, 3. -1 \right) . \] In particular, \begin{align*} T\,{\bf e}_1 &= T\,{\bf i} = {\bf e}_1 - \frac{2}{7} \left( 2, 3, -1 \right) = \left( 1, 0, 0 \right) - \frac{2}{7} \left( 2, 3, -1 \right) , \\ T{\bf e}_2 &= T\,{\bf i} = {\bf e}_2 - \frac{2}{7} \left( 2, 3, -1 \right) = \left( 0, 1, 0 \right) - \frac{2}{7} \left( 2, 3, -1 \right) , \ T{\bf e}_3 &= T\,{\bf i} = {\bf e}_3 - \frac{2}{7} \left( 2, 3, -1 \right) = \left( 0, 0, 1 \right) - \frac{2}{7} \left( 2, 3, -1 \right) . \end{align*} These vectors form the matrix T in standard basis: \[ {\![ T]\!] = \frac{1}{7} \begin{bmatrix} 3 & -4& -4 \\ -6 &1 & -6 \\ 2 & 2& 9 \end{bmatrix} . \]

{1, 0, 0} - (2/7)*{2, 3, -1}
{3/7, -(6/7), 2/7}
We check that the reflection matrix is orthogonal:
A = (1/7)*{{3,-4,-4}, {-6,1,-6}, {2,2,9}}; Transpose[A] . A
Roger
   ■
End of Example 2

  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. Coxeter, H.S.M. (1969), Introduction to Geometry (2nd ed.), New York: John Wiley & Sons, ISBN 978-0-471-50458-0
  3. Dunn, F. and Parberry, I. (2002). 3D math primer for graphics and game development. Plano, Tex.: Wordware Pub.
  4. 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
  5. Matrices and Linear Transformations
  6. Rogers, D.F., Adams, J. A., Mathematical Elements for Computer Graphics, McGraw-Hill Science/Engineering/Math, 1989.
  7. Watt, A., 3D Computer Graphics, Addison-Wesley; 3rd edition, 1999.