Matrix Rotation

Rotate vectors in 2D and 3D using rotation matrices

Cartesian vs Polar Coordinates

A point in the plane can be described in Cartesian coordinates as \((x, y)\). Alternatively, we can represent the same point using polar coordinates \((r, \theta)\), where \(r\) is the distance from the origin and \(\theta\) is the angle.

Polar coordinates diagram
Polar coordinate formulas

In the diagram above, \(r\) is the hypotenuse of a right-angled triangle.

Coordinate Relations:

\(x = r\cos(\theta)\) and \(y = r\sin(\theta)\)

2D Rotation and Rotation Matrix

The x-position can be calculated from the radius \(r\) and the angle \(\theta\) according to:

x = r cos(theta)

The y-position is calculated accordingly:

y = r sin(theta)

Rotate a Point by an Angle \(\varphi\)

If we rotate the point \((x, y)\) by the angle \(\varphi\), the new coordinates \((x', y')\) are:

x' formula y' formula
Rotation diagram

In matrix form, a rotation is written as:

2D rotation matrix equation
Rotation Matrix:

The 2D rotation matrix for an angle \(\varphi\) is:

\(\displaystyle R(\varphi)=\begin{bmatrix}\cos(\varphi) & -\sin(\varphi) \\ \sin(\varphi) & \cos(\varphi)\end{bmatrix}\)

Worked Example (\(\varphi = 30^\circ\))

The example below shows a rotation matrix for \(\varphi = 30^\circ\):

Rotation matrix for 30 degrees
Rotate the vector (1, 0)

With this matrix, the position vector for the point \((1,0)\) becomes:

Rotation of (1,0) by 30 degrees

3D Rotation Matrices

In three-dimensional space, rotations are defined around a chosen axis. Below are counter-clockwise rotation matrices around the coordinate axes.

Rotation About the x-axis

Rotation about x-axis

Rotation About the y-axis

Rotation about y-axis

Rotation About the z-axis

Rotation about z-axis
Conventions:

Rotation direction (clockwise vs counter-clockwise) depends on the chosen coordinate system and the sign convention for \(\varphi\). This page uses counter-clockwise rotations.

Key Points to Remember

2D Rotation
\(\mathbf{v}' = R(\varphi)\mathbf{v}\) with sine/cosine matrix
Polar Link
\(x=r\cos(\theta)\), \(y=r\sin(\theta)\) explain the rotation formulas
3D Rotations
Use axis-specific rotation matrices around x, y, z






Is this page helpful?            
Thank you for your feedback!

Sorry about that

How can we improve it?