Register
handmade.network»Forums»Q: Change of basis and similar matrices
Abhaya Uprety
7 posts
Q: Change of basis and similar matrices
3 weeks, 4 days ago Edited by Abhaya Uprety on May 20, 2021, 5:18 p.m. Reason: Initial post
Let T be the linear transformation on the vector space V; let { v1, v2 ... vn }
and let { w1, w2, ... wn } be 2 different set of basis vectors that span V. If matrix
A defines the linear transformation T for { v1, v2, .. vn } and matrix B defines T for
{ w1, w2, ... wn }, how are A and B related.

If P is the change of basis Matrix then,

A = Inverse(P) * B * P is the relation. Which also means that A and B are similar matrices.

I am able to derive P, but I could not derive how they are similar.

Wikipedia has this under Endomorphisms, but I could not figure it out.
123 posts / 1 project
Q: Change of basis and similar matrices
3 weeks, 3 days ago Edited by Dawoodoz on May 21, 2021, 5:24 p.m.
A and B are the same real world transformation expressed in different coordinate systems.

Imagine that A and B are two guys sitting on each side of a restaurant table with their own system of forward, backward, left and right. Person A moves his plate to the left, but for person B to do the same transform from his point of view (basis), he must move it to his right to get A's left.

For rotation only, it's like rotating a ball 90 degrees to the right around the forward axis (inverse of P), spinning it forward (B) and then rotating it back 90 degrees to the left around the forward axis (P). Instead of having the ball leaning forward as a result, it's rotated clockwise around the up axis (A) due to this temporary change in basis (inverse(P) and P). The basis change is then the same as if your hand rotated 90 degrees to the left around the forward axis (P) before trying to spin the ball forward from its local point of view using the same finger movement. A therefore describes the B transform from another coordinate system, which is a change in coordinate system describing locations. Convert to other coordinate system, apply transform in that system and convert back to your system.

Easy to keep track of if each transform describes which system it goes to and from. If you have 5 meters and want to add 100 centimeters. You apply a transform from the meter system to centimeters using a one-dimensional scaling matrix of the same origin, add 100 and scale back with the centimeter to meter transform. Then you have 6 meters as the result of adding 100 cm. If you change the basis for the +100cm transform, you get a +1m transform. This trick is useful for speeding up rendering by preparing matrices in advance for different coordinate systems.
Abhaya Uprety
7 posts
Q: Change of basis and similar matrices
6 days, 17 hours ago
Hey @Dawoodoz, I have been sitting on this for weeks, and haven't responded yet. Just couldn't squeeze all the linear algebra through wikipedia, just too beginner unfriendly and have been referring to my university book. Anyway, here is the response:

"A and B are the same real world transformation expressed in different coordinate systems.", that is essentially how I think about similar matrices as well. "Imagine that A and B are two guys ... A's left.", is very insightful and so is the meter/centimeter illustration of change of basis concept in your final paragraph. The paragraph before that however, one that starts with "For rotation only, it's like rotating a ball...", I couldn't quite wrap it neatly, but I think I got what you were trying to say there.

Anyway, I have attached the proof of A = Inverse(P) * B * P below as image:


This is aside answer but just wanted to share. Much like @Dawoodoz 's explanations, I do this with maths all the time, where I imagine shapes and curves and real world scenarios and draw out an example behind an equation or some mathematical concept and build up my intuition and that satisfies me enough so that I am able to move forward with the application. Unless I have that intuition I just can't move forward. In cases, where equations are really surprising or in cases where I am unable to build intution, I have to understand the proof. In this case of 3d rotations, it started after seeing the implementation of hmm_mat4 HMM_PREFIX(Rotate)(float Angle, hmm_vec3 Axis), from handmade math header file library, which was so different than what I had expected, and that got me into axis angle representation, and the derivations, and at this point it has got me into almost a month of linear algebra. I have hit a stop point thankfully.