Computer Graphics Notes
Rotation
Pitch (Rotate around x-axis):
R x = [ 1 cos θ − sin θ sin θ cos θ ]
\begin{equation}
\mathbf R_x=
\begin{bmatrix*}[r]
1 & &\\
& \cos\theta & -\sin\theta\\
& \sin\theta & \cos\theta
\end{bmatrix*}
\end{equation}
R x = 1 cos θ sin θ − sin θ cos θ
Roll (Rotate around y-axis)
R y = [ cos θ − sin θ 1 sin θ cos θ ]
\begin{equation}
\mathbf R_y=
\begin{bmatrix*}[r]
\cos\theta & & -\sin\theta\\
& 1 & \\
\sin\theta & & \cos\theta
\end{bmatrix*}
\end{equation}
R y = cos θ sin θ 1 − sin θ cos θ
Yaw (Rotate around z-axis)
R z = [ cos θ − sin θ sin θ cos θ 1 ]
\begin{equation}
\mathbf R_z=
\begin{bmatrix*}[r]
\cos\theta & -\sin\theta &\\
\sin\theta & \cos\theta &\\
& & 1\\
\end{bmatrix*}
\end{equation}
R z = cos θ sin θ − sin θ cos θ 1
Proof in 2-D:
{ x = r cos α y = r sin α → { x ′ = r cos ( α + θ ) = x cos θ − y sin θ y ′ = r sin ( α + θ ) = x sin θ + y cos θ , ↓ { x ′ = x cos θ − y sin θ y ′ = x sin θ + y cos θ → { x ′ = x cos θ − y sin θ y ′ = x sin θ + y cos θ , ↓ [ cos θ − sin θ sin θ cos θ ] [ x y ] = [ x ′ y ′ ] .
\begin{gathered}
\begin{cases}
x=r\cos\alpha\\
y=r\sin\alpha
\end{cases}
\to
\begin{cases}
x^\prime=r\cos(\alpha+\theta)=x\cos\theta-y\sin\theta\\
y^\prime=r\sin(\alpha+\theta)=x\sin\theta+y\cos\theta
\end{cases}
,\\\downarrow\\
\begin{cases}
x^\prime=x\cos\theta-y\sin\theta\\
y^\prime=x\sin\theta+y\cos\theta
\end{cases}
\to
\begin{cases}
x^\prime=x\cos\theta-y\sin\theta\\
y^\prime=x\sin\theta+y\cos\theta
\end{cases}
,\\\downarrow\\
\begin{bmatrix}
\cos\theta & -\sin\theta\\
\sin\theta & \cos\theta
\end{bmatrix}
\begin{bmatrix}
x\\y
\end{bmatrix}
=
\begin{bmatrix}
x^\prime\\y^\prime
\end{bmatrix}
.
\end{gathered}
{ x = r cos α y = r sin α → { x ′ = r cos ( α + θ ) = x cos θ − y sin θ y ′ = r sin ( α + θ ) = x sin θ + y cos θ , ↓ { x ′ = x cos θ − y sin θ y ′ = x sin θ + y cos θ → { x ′ = x cos θ − y sin θ y ′ = x sin θ + y cos θ , ↓ [ cos θ sin θ − sin θ cos θ ] [ x y ] = [ x ′ y ′ ] .
Scaling
x ′ = s x ⋅ x y ′ = s y ⋅ y ↓ [ x ′ y ′ ] = [ s x s y ] [ x y ]
\begin{gathered}
\begin{aligned}
x^\prime=s_x\cdot x\\
y^\prime=s_y\cdot y
\end{aligned}
\\\downarrow\\
\begin{bmatrix}x^\prime\\y^\prime\end{bmatrix}
=
\begin{bmatrix}
s_x &\\
& s_y
\end{bmatrix}
\begin{bmatrix}x\\y\end{bmatrix}
\end{gathered}
x ′ = s x ⋅ x y ′ = s y ⋅ y ↓ [ x ′ y ′ ] = [ s x s y ] [ x y ]
Translation
x ′ = x + t x x ′ = y + t y ↓ [ x ′ y ′ 1 ] = [ 1 t x 1 t y 1 ] [ x y 1 ]
\begin{gathered}
\begin{aligned}
x^\prime=x+t_x\\
x^\prime=y+t_y
\end{aligned}
\\\downarrow\\
\begin{bmatrix}x^\prime\\y^\prime\\1\end{bmatrix}
=
\begin{bmatrix}
1 & & t_x\\
& 1 & t_y\\
& & 1
\end{bmatrix}
\begin{bmatrix}x\\y\\1\end{bmatrix}
\end{gathered}
x ′ = x + t x x ′ = y + t y ↓ x ′ y ′ 1 = 1 1 t x t y 1 x y 1