$Post :=
If[MatrixQ[#1],
MatrixForm[#1], #1] & (* outputs matrices in MatrixForm*)
Remove[ "Global`*"] // Quiet (* remove all variables *)
2D Rotations
A rotation on the plane (2D, for short) about the origin has only one parameter, the angle, which defines the amount of rotation. The standard convention found in most math books is to consider counterclockwise rotation positive and clockwise rotation negative. We can do rotation about the origin using matrix multiplication.
A rotation matrix is a transformation performed by matrix multiplication on vectors that results in rotating of the vector by angle θ in counterclockwise direction. WE use matrices in bracket notation when they are considered as operators on column vectors and we embrace matrices in parentheses when they operate on row vectors from right.
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.
Frame Rotation -- Points fixed
Let us consider a plane ℝ², which is the Cartesian product of two real number lines, ℝ × ℝ. Upon choosing two perpendicular lines with uniform grid, we obtain a coordinate system or a frame. Since a grid has a natural order, these two lines become axes and usually they are visualized with arrows. The point of intersection of these two lines is called the origin. The horizontal line, known as abscissa is usually labeled with x, and the vertical line pointed up is known as ordinate, we label it will letter y.
Note that, these two axes are ordered in the plane such that
a 90 degree counter-clockwise rotation about the origin transfers the
positive x-axis into the positive ordinate. The origin represents the zero point on each coordinate axis and
is designated by the ordered pair of real numbers (0, 0). A unit vector on abscissa is usually denoted by i = (1, 0) ) or e₁, and the unit vector on ordinate is denoted by j = (0, 1) or e₂.
We fix a point P(x₀, y₀) in the xy-plane, which is also identified by vector \( \displaystyle \quad {\bf r} = \overline{OP} = (x_0 , y_0 )\quad \) because point P and vector r have the same coordinates. We are going to determine new coordinates of point P when frame O(x, y) is rotated by angle θ in counterclockwise direction (which is considered to be positive). For simplicity, we drop subscripts of point/vector in further derivation. Let the coordinates of P in the new frame
be (X, Y), which can be expresed through its previous coordinates (x, y).
From Figure 1 we notice that the angle between the vector
\( \displaystyle \quad {\bf r} = \overline{OP} \quad \) b>r and the rotated X-axis is θ − ϕ.
Let r be the length of the vector r and ϕ be
the angle between the vector and the positive x axis. Then, using
ordinary right triangle trigonometry, we see that
\begin{align*}
X &= r\,\cos \left( \theta - \phi \right) ,
\\
Y &= r\,\sin \left( \theta - \phi \right)
\end{align*}
Thus the desired relationship between old coordinates and new ones becomes
\begin{align*}
X &= x\,\cos\phi + y\,\sin\phi ,
\\
Y &= y\,\cos\phi - x\,\sin\phi .
\end{align*}
If you are familiar with matrix multiplication (see Part 2 of this tutorial), we can replace a pair of equations with a concise formula. Wring coordinates as column vectors, we get
\begin{equation} \label{Eq2D.1}
\begin{bmatrix} X \\ Y \end{bmatrix} = \begin{bmatrix} \cos\phi & \sin\phi \\ -\sin\phi & \cos\phi \end{bmatrix} \begin{pmatrix} x \\ y \end{pmatrix}
\end{equation}
.
When coordinates of point P are written as rows, we obtain
\begin{equation} \label{Eq2D.2}
\begin{bmatrix} X & Y \end{bmatrix} = \begin{bmatrix} x & y \end{bmatrix} \begin{pmatrix} \cos\phi & -\sin\phi \\ \sin\phi & \cos\phi \end{pmatrix} .
\end{equation}
is called the rotation matrix. Letter "T" stands for transposition. We embrace this matrix into brackets to emphasize that this matrix operates on column vectors upon multiplication from left. We will use parentheses when row vector is multiplied by matrix from right.
Point Rotation -- Frame fixed
We begin with rotating a point P(x₀, y₀) in the xy-plane about the origin through an angle θ in counterclockwise direction. We demonstrate derivation of the rotation matrix in two ways. First, we use trigonometric relations, and then show that the same matrix can be obtained based on rotations of basic vectors i = (1, 0) and j = (0, 1),
Suppose that a given point P(x, y) is moved under rotation by angle ϕ into a new point Q(X, Y). In order to derive the rotation matrix, we recognize that the new point Q will be the same distance from the origin as the starting point P. So both points P and Q lie on the circle centered at the origin of radius r = |OP|. The point Q is just an extra angle ϕ, as measured from the positive abscissa (= x-axis) relative to the position of P at this circle. If the point P is at angle θ, then the new point Q is at the angle ϕ + θ. Since all the points on the circle of radius r with center at the origin can be written as \( \displaystyle r\,e^{{\bf j}\alpha} = \left( r\,\cos\alpha , r\,\sin\alpha \right) \) for some real number α. We know that point P has coordinates \( \displaystyle r\,e^{{\bf j}\theta} = \left( r\,\cos\theta , r\,\sin\theta \right) , \) while point Q has coordinates \( \displaystyle r\,e^{{\bf j}(\phi + \theta )} = \left( r\,\cos (\phi + \theta ) , r\,\sin (\phi + \theta ) \right) , \) where j is the unit vector in the positive vertical direction on complex plane ℂ so j² = −1.
In order to determine the rotation matrix, we express coordinates of point Q through coordinates of point P. To accomplish this task, we use trigonometric identities and delegate this job to Mathematica:
where we embrace the rotation matrix into brackets to emphasize that this matrix acts on column vectors upon multiplication from left. Since matrices can operate either on column vectors from left or on row vectors from right, we distinguish these matrix operators by embracing matrices either in brackets (when acting on column vectors) or in parentheses (when acting on row vectors). Note that row rotation matrix is transposed of the column rotation matrix.
Actually, the deriation of rotation matrix above is euivalent to multiplication of vector z = OP on complex plane ℂ by complex number
\( \displaystyle \ e^{{\bf j}\theta} .\ \)
In order to implement this approach, you need to recall complex numbers.
We can derive the rotation matrix \eqref{EqPlane.2} by considering transformation of base vectors i = (0, 1) and j = (0, 1).
Moreover, rotation matrices are orthogonal matrices (A−1 = AT) with a determinant equals to 1.
Example 1:
For illustration of rotations, we consider a unit square with verteces O(0, 0), A(1, 0), B(1, 1), and C(0, 1). Suppose we want to find coordinates of these points in a new system of coordinates obtained by rotation with respect to the origin by 60° (= π/3). So we apply formula (1) to each vertex. First, we evaluate elements of the corresponding rotation matrix
\[
\cos\left( \frac{\pi}{3} \right) = \frac{1}{2}, \qquad \sin\left( \frac{\pi}{3} \right) = \frac{\sqrt{3}}{2}.
\]
Cos[Pi/3]
1/2
Sin[Pi/3]
Sqrt[3]/2
Therefore, the rotation matrix is
\[
{\bf R}\left( \frac{\pi}{3} \right) = \begin{bmatrix} \frac{1}{2} & \frac{\sqrt{3}}{2} \\ -\frac{\sqrt{3}}{2} & \frac{1}{2} \end{bmatrix} = \begin{pmatrix} \frac{1}{2} & -\frac{\sqrt{3}}{2} \\ \frac{\sqrt{3}}{2} & \frac{1}{2} \end{pmatrix}
\]
Then we apply formula (1) and obtain
\begin{align*}
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 0 \end{bmatrix} \,{\bf R} = \begin{bmatrix} 0 & 0 \end{bmatrix} ,
\\
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 0 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{1}{2} & -\frac{\sqrt{3}}{2} \end{bmatrix}
\\
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 1 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{1+ \sqrt{3}}{2} & -\frac{1-\sqrt{3}}{2} \end{bmatrix} ,
\\
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 1 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{\sqrt{3}}{2} & \frac{1}{2}\end{bmatrix} .
\end{align*}
R = {{1/2, Sqrt[3]/2}, {-Sqrt[3]/2, 1/2}};
R . {1, 0}
{1/2, -(Sqrt[3]/2)}
R . {1, 1}
{1/2 + Sqrt[3]/2, 1/2 - Sqrt[3]/2}
R . {0, 1}
{Sqrt[3]/2, 1/2}
We plot rotation of the frame:
Roger plots
Now we rotate this unit square by 60°. We can use transposed matrix from the previous part as the rotation matrix.
\begin{align*}
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 0 \end{bmatrix} \,{\bf R}^{\mathrm T} = \begin{bmatrix} 0 & 0 \end{bmatrix} ,
\\
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 0 \end{bmatrix} \,{\bf R} = \begin{bmatrix} \frac{1}{2} & \frac{\sqrt{3}}{2} \end{bmatrix}
\\
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 1 & 1 \end{bmatrix} \,{\bf R}^{\mathrm T} = \begin{bmatrix} \frac{1- \sqrt{3}}{2} & -\frac{1+\sqrt{3}}{2} \end{bmatrix} ,
\\
\begin{bmatrix} X & Y \end{bmatrix} &= \begin{bmatrix} 0 & 1 \end{bmatrix} \,{\bf R}^{\mathrm T} = \begin{bmatrix} -\frac{\sqrt{3}}{2} & \frac{1}{2}\end{bmatrix} .
\end{align*}
Transpose[R . {1, 0}
{1/2, Sqrt[3]/2}
Transpose[R . {1, 1}
{1/2 - Sqrt[3]/2, 1/2 + Sqrt[3]/2}
Transpose[R . {0, 1}
{-(Sqrt[3]/2), 1/2}
Roger plots
■
End of Example 1
Observarion:
Rotations in ℝ² are represented by matrices of the group
50(2). However, there ae two kinds of rotations: rotation of the coordinate frame and rotation of a point(vector). Note that the rotation operator (or matrix) for the one case is simply the transpose of the rotation operator for the other case.
Compositions
We now consider a case when one rotation is followed by
another one.
Suppose a rotation of the initial coordinate frame (points fixed)
through an angle α is followed by a rotation of the resulting coordinate frame through an angle β. Clearly the result is a rotation of the initial coordinate frame (points fixed) through an angle α + β,
as illustrated in Figure 4.
We consider a sequence of rotations when
the initial coordinate frame (points fixed)
through an angle α is followed by a rotation of the resulting coordinate frame through an angle β. Clearly the result is a rotation of the initial coordinate system (points fixed) through an angle of α + β, as illustratrated in Figure 4. The corresponding matrices of rotation are
where \( \displaystyle \quad {\bf v}_2 = \begin{bmatrix} x_2 \\ y_2 \end{bmatrix} , \quad {\bf v}_1 = \begin{bmatrix} x_1 \\ y_1 \end{bmatrix} , \quad {\bf v} = \begin{bmatrix} x \\ y \end{bmatrix} . \quad \)
This equation shows that the rotation operator for the sequence of
rotations is exactly the product of the two individual rotation operators Rβ and Rα. Multiplication of these two rotation matrices yields
We notice immediately that this final matrix does not depend on the order of matrices in their multiplication. It is just the rotation
operator representing a rotation of the coordinate frame through an
angle α + β, while the points (or vectors) remain fixed.
Example 2:
We provide a geometrical "proof" of the Pythagorus theorem and as a side effect demonstrate usefulness of computer solve for its illustration. So we start with a right triangle
Note that using the coordinates indicated by the gridlines we can describe the beginning and ending positions of the square of dashed lines. It seems to me that there may be a matrix operation you might see that I do not which would simplify this.
■
End of Example 2
Reflections
A rotation in the plane is closely related to reflection operation---a transformation that produces a mirror image of an object relative to anaxis of reflection (which is a fixed point for this transformation). Every rotation by angle θ can be formed by a pair of reflections. Suppose we have two lines (through the origin) L₁ and L₂ having angle θ between them. An arbitrary point P on the plane can be rotated by angle 2θ by reflecting P with respect to L₁ into P₁, which then is reflected into point P₂ with respect to line L₂.
Let a reflection about a line L through the origin which makes an angle θ with the abscissa (x-axis) be denoted as Ref(θ). Suppose that these reflections operate on all points on the plane, and let these points be represented by position vectors. Then a reflection can be acomplished by applying orthogonal matrix (from left on column vectors or from right on row vectors) that performs mirrowing about the line that passes through the origin and is perpendicular to the unit vector \( \displaystyle \ \hat{\bf n} = \left( n_x, n_y \right) \ \) is given by
Since axis of reflection goes through the origin, every vector in &Riof;² can be separated in two parts:
\[
{\bf v} = {\bf v}_{\|} + {\bf v}_{\perp} ,
\]
where v∥ is the projection of v on the axis and v⊥ is perpendicular to the axis. Then action of reflection operation on any vector can be expressed as
Consider the point P(2,1). Without using matrix multiplication, find the resulting point undr rotation about the origin by angles π/2 and π/4.
Given a point P on the plane ℝ², let Q be the point corresponding to the rotation of P in counterclockwise direction about the origin through an angle θ. Let R be the point corresponding to the rotation of Q in counterclockwise direction about the origin through an angle ϕ. Verify that
\[
\mathbf{R}[\phi ]\,\mathbf{R}[\theta ] = \mathbf{R}[\phi + \theta ] ,
\]
where R[θ] is the rotation matrix according to formula (1). Does it mean that products of rotation matrices are commutative?
Find the coordinates of the point Q corresponding to the point P(3, 2) that has been rotated in counterclockwise direction about the origin through an angle θ = 2π/3.
Anton, Howard (2005), Elementary Linear Algebra (Applications Version) (9th ed.), Wiley International
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