How To: Vector Rotation Intuition. Tying up with Transformations

Introduction

Let’s start with something simple. We want to rotate a vector along x-axis at a certain angle. This is quite trivial to compute and you just need knowledge of rudimentary trigonometry to compute the resulting coordinates of vector. Let’s see if we can wrap around head around vector rotation intuition.

Basis Visualization
Basis Visualization

Let’s kick it up a notch and try to rotate Y-Axis in positive direction to get a new vector. This too can be easily computed with a few simple calculations. But! since we are considering counter-clockwise rotation to be positive(Left-Handed System), in our example, X’ should receive a negative value. How can we reason about this?

Here’s what’s happening: In out Left-Handed system, positive rotation around Z-Axis happens from +X -> +Y -> -X -> -Y -> +X. As we are rotating our Y-Axis, there’s an additional offset of PI/2 that needs to be added to rotation. This gives:
X’ = Cos(90 + A) = Cos(90)Cos(A) – Sin(90)Sin(A) = -Sin(A)
Y’ = Sin(90 + A) = Sin(90)Cos(A) + cos(90)Sin(A) = Cos(A)
Now we see a negative sign showing up in the computation of X’.
So, we ended up having to add an offset that would let us reach Y-Axis from X-Axis and then add the actual rotation that we want Y-Axis to rotate.

Viewing Through Y-Axis

This is great, but here’s another way of thinking about it:
Let’s take a peek at how rotation looks from Y-Axis’ perspective.
We are still in Left-Handed space and our Z-Axis hasn’t changed. In Y’s view, it is the positive axis that starts the rotation and on rotating counter-clockwise by 90 degrees, it reaches -ve X-Axis.
Upon rotating some angle, it arrives at (YL, XL). This is what the Y-Axis sees and these coordinate are what we get in the local space of Y-Axis.
Now that we have local coordinates, we just need a transformation matrix to compute the actual position in world space. Refer this for a refresher on local to world computation.

This matrix is quite easy to write as we just swapped X-Axis with Y-Axis and Y-Axis with -ve X-Axis.

0-1
10
Transformation(Column-Major)

As an example, let’s rotate a vector along Y-Axis by 45 degrees.
– (YL, XL) are (1/sqrt(2), 1/sqrt(2))
– On applying the transformation matrix to the vector above, we get (-1/sqrt(2), 1/sqrt(2)). These are indeed the world space coordinates that we desire.


One response to “How To: Vector Rotation Intuition. Tying up with Transformations”

Leave a Reply

Your email address will not be published. Required fields are marked *