# Matrices rotation

Description of matrices and geometric rotation with examples

## Rotation

A polar coordinate can be described by a pair of numbers$$(x, y)$$. The numbers are the distance from the y axis (x), and from the x axis (y) in the coordinate system. Any points to the left of the y-axis will have a negative x coordinate. Any points below the x axis, will have a negative y coordinate.

Instead with the term $$(x, y)$$ , we can describe the point with radius $$r$$ and the angle $$θ$$ as $$(r, θ)$$.

$$\displaystyle r=\sqrt{x^2+y^2}$$             $$\displaystyle tan(θ)=\frac{y}{x}$$

In the diagram above, $$r$$ is the hypotenuse of a right-angled triangle.

The x-position can be calculated from the radius $$r$$ and the angle $$θ$$ according to the following formula.

$$x=r·cos(θ)$$

The y-position is calculated accordingly from the formula

$$y=r·sin(θ)$$

In the following figure, we have rotated the point (x, y) by the angle $$φ$$. So, we have now

$$x'=r·cos(θ+φ)$$        $$y'=r·sin(θ+φ)$$

When we write this in a matrix form it looks like this

$$\displaystyle \left[\matrix{x'\\y'}\right] = \left[\matrix{cos(φ) & - sin(φ) \\ sin(φ) & cos(φ)}\right] \left[\matrix{x \\ y }\right]$$

The example below shows a matrix that rotates the vector by an angle of $$φ = 30°$$.

$$\displaystyle \left[\matrix{cos(30) & - sin(30) \\ sin(30) & cos(30)}\right] = \left[\matrix{0.866 & - 0.5 \\ 0.5 & 0.866}\right]$$

With this Matrix the position vector for the point $$(1,0)$$ becomes

$$\displaystyle \left[\matrix{x' \\ y'}\right] = \left[\matrix{0.866 & - 0.5 \\ 0.5 & 0.866}\right] · \left[\matrix{1 \\ 0}\right] =\left[\matrix{0.866 \\ 0.5}\right]$$

A rotation in 3-space, counter clockwise shows the matrices below

$$\displaystyle \left[\matrix{1 & 0 & 0 \\ 0 & cos(φ) & - sin(φ) \\ 0 & sin(φ) & cos(φ) }\right]$$
$$\displaystyle \left[\matrix{cos(φ) & 0 & sin(φ) \\ 0 & 1 & 0 \\ - sin(φ) & 0 & cos(φ) }\right]$$
$$\displaystyle \left[\matrix{cos(φ) & - sin(φ) & 0 \\ sin(φ) & cos(φ) & 0 \\ 0 & 0 & 1}\right]$$