Rotate a triangle with the exact rational rotation where cos = 4/5 and sin = 3/5.

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=[45353545]M=\begin{bmatrix}\frac{4}{5}&\frac{-3}{5}\\\frac{3}{5}&\frac{4}{5}\end{bmatrix}
2D transform triangleA dim original triangle and transformed vertices computed from the algebra.

Step 2 — Move vertex A

Multiply the matrix by vertex A.

A=[45353545][11]=[451+(35)1351+451]=[1575]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}}
2D transform triangleA dim original triangle and transformed vertices computed from the algebra.A'

Step 3 — Move vertex B

Multiply the matrix by vertex B.

B=[45353545][31]=[453+(35)1353+451]=[95135]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}}
2D transform triangleA dim original triangle and transformed vertices computed from the algebra.A'B'

Step 4 — Move vertex C

Multiply the matrix by vertex C.

C=[45353545][12]=[451+(35)2351+452]=[25115]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}}
2D transform triangleA 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}
2D transform triangleA 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.