Member-only story

Demystifying Rotation Matrix

How to rotate a vector in R²

Mert Atli
TDS Archive
6 min readNov 1, 2023

--

A rotation matrix is like a magical tool in the world of linear algebra, designed to spin vectors around in space with precision and ease. Imagine you have a vector, a little arrow pointing somewhere in space, and you want to turn it around a certain point, like spinning a key around a keyring. That’s exactly what a rotation matrix helps you do.

To see how the rotation matrix emerges, lets start with a vector in R² and try to rotate it along horizontal axis.

Rotating a vector in R²

The figure below shows a vector v in R² that makes the angle a with horizontal axis. Let’s say that we want to rotate it ‘b degrees’ counter-clock wise along the horizontal axis, which is denoted by v’.

From v to v’ via rotation

As we can see, the rotation just changes the direction of v and keeps the length(a.k.a ‘magnitude’) same.

In R², we can represent the vector v as the ordered tuple (m, n) with first element in horizontal axis, and the second element in the vertical axis. From trigonometry, we know that the coordinates of v=(m, n) can be represented as (||v||.cos(a), ||v||.sin(a)):

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

No responses yet