Example
Use the exact rational rotation with cos = 4/5 and sin = 3/5.
highlighted = computed this step
Step 1 — Set up
Use column vectors with matrix times vertex.
M = [ 4 5 − 3 5 3 5 4 5 ] M=\begin{bmatrix}\frac{4}{5}&\frac{-3}{5}\\\frac{3}{5}&\frac{4}{5}\end{bmatrix} M = [ 5 4 5 3 5 − 3 5 4 ]
2D transform triangle A dim original triangle and transformed vertices computed from the algebra.
Step 2 — Move vertex A
Multiply the matrix by vertex A.
A ′ = [ 4 5 − 3 5 3 5 4 5 ] [ 1 1 ] = [ 4 5 ⋅ 1 + ( − 3 5 ) ⋅ 1 3 5 ⋅ 1 + 4 5 ⋅ 1 ] = [ 1 5 7 5 ] A'=\begin{bmatrix}\frac{4}{5}&\frac{-3}{5}\\\frac{3}{5}&\frac{4}{5}\end{bmatrix}\begin{bmatrix}1\\1\end{bmatrix}=\begin{bmatrix}\frac{4}{5}\cdot1+\left(\frac{-3}{5}\right)\cdot1\\\frac{3}{5}\cdot1+\frac{4}{5}\cdot1\end{bmatrix}=\hlmath{\begin{bmatrix}\frac{1}{5}\\\frac{7}{5}\end{bmatrix}} A ′ = [ 5 4 5 3 5 − 3 5 4 ] [ 1 1 ] = [ 5 4 ⋅ 1 + ( 5 − 3 ) ⋅ 1 5 3 ⋅ 1 + 5 4 ⋅ 1 ] = [ 5 1 5 7 ]
2D transform triangle A dim original triangle and transformed vertices computed from the algebra. A'
Step 3 — Move vertex B
Multiply the matrix by vertex B.
B ′ = [ 4 5 − 3 5 3 5 4 5 ] [ 3 1 ] = [ 4 5 ⋅ 3 + ( − 3 5 ) ⋅ 1 3 5 ⋅ 3 + 4 5 ⋅ 1 ] = [ 9 5 13 5 ] B'=\begin{bmatrix}\frac{4}{5}&\frac{-3}{5}\\\frac{3}{5}&\frac{4}{5}\end{bmatrix}\begin{bmatrix}3\\1\end{bmatrix}=\begin{bmatrix}\frac{4}{5}\cdot3+\left(\frac{-3}{5}\right)\cdot1\\\frac{3}{5}\cdot3+\frac{4}{5}\cdot1\end{bmatrix}=\hlmath{\begin{bmatrix}\frac{9}{5}\\\frac{13}{5}\end{bmatrix}} B ′ = [ 5 4 5 3 5 − 3 5 4 ] [ 3 1 ] = [ 5 4 ⋅ 3 + ( 5 − 3 ) ⋅ 1 5 3 ⋅ 3 + 5 4 ⋅ 1 ] = [ 5 9 5 13 ]
2D transform triangle A dim original triangle and transformed vertices computed from the algebra. A' B'
Step 4 — Move vertex C
Multiply the matrix by vertex C.
C ′ = [ 4 5 − 3 5 3 5 4 5 ] [ 1 2 ] = [ 4 5 ⋅ 1 + ( − 3 5 ) ⋅ 2 3 5 ⋅ 1 + 4 5 ⋅ 2 ] = [ − 2 5 11 5 ] C'=\begin{bmatrix}\frac{4}{5}&\frac{-3}{5}\\\frac{3}{5}&\frac{4}{5}\end{bmatrix}\begin{bmatrix}1\\2\end{bmatrix}=\begin{bmatrix}\frac{4}{5}\cdot1+\left(\frac{-3}{5}\right)\cdot2\\\frac{3}{5}\cdot1+\frac{4}{5}\cdot2\end{bmatrix}=\hlmath{\begin{bmatrix}\frac{-2}{5}\\\frac{11}{5}\end{bmatrix}} C ′ = [ 5 4 5 3 5 − 3 5 4 ] [ 1 2 ] = [ 5 4 ⋅ 1 + ( 5 − 3 ) ⋅ 2 5 3 ⋅ 1 + 5 4 ⋅ 2 ] = [ 5 − 2 5 11 ]
2D transform triangle A dim original triangle and transformed vertices computed from the algebra. A' B' C'
Step 5 — Result
The transformed triangle is complete.
transformed triangle complete \text{transformed triangle complete} transformed triangle complete
2D transform triangle A dim original triangle and transformed vertices computed from the algebra. A' B' C'
rotate-rational-3-4-5
This exact rational rotation is a teachable exception. Arbitrary angles usually send integer pixel positions to irrational coordinates, so bitmap rotation must round or resample and can introduce aliasing.