A Quick Trick for Finding a Matrix Transformation Formula
Perform the desired transformation on identity matrix to get a left-multiplier, and maybe transpose the output.
Want to get notified about new posts? Join the mailing list and follow on X/Twitter.
Here’s a trick that you can (often) use to find a desired matrix transformation formula: just find the output of the transformation for the identity matrix.
For instance, if you want to rotate 90 degrees clockwise, then you want to take the identity matrix
and turn it into the following:
Now, sometimes you have to tweak the result by transposing it afterwards – we don’t catch this in the above reasoning since the identity matrix is symmetric.
But you can catch that by double-checking that your transformation works in a more general case as follows:
So, if you want to rotate a matrix 90 degrees clockwise then you use rotate90(X) = transpose(antiDiag * X)
where antiDiag
is the antidiagonal matrix with 1’s on the anti-diagonal.
Want to get notified about new posts? Join the mailing list and follow on X/Twitter.