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

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.

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=[45−353545]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′=[45−353545][11]=[45⋅1+(−35)⋅135⋅1+45⋅1]=[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′=[45−353545][31]=[45⋅3+(−35)⋅135⋅3+45⋅1]=[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′=[45−353545][12]=[45⋅1+(−35)⋅235⋅1+45⋅2]=[−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'