Confusion With CFrame Matrix Vectors

Hello devs,

I’ve been learning advanced CFrame, like CFrame matrix. I’m a bit confused though.

In the image below me, I used a script to find the components of the current CFrame of the grey object. The transparent axes represent the global axes and the opaque ones represent the local axes.


Now in the picture above, it looks normal, right? All of the vectors are aligned to their global axis.


The same can be said for this photo when the object is rotated 90° on the y-axis.


However, when rotating this object 45° on the z-axis, totally different numbers are shown. Can anybody explain this? Thanks in advance.

How familiar are you with linear algebra?

In 3D affine transformation, rotation around an axis can be defined with the following matrices:
image

If we took your first example, rotating 90 degrees around the y-axis, then cos(90 degrees) is 0 and sin(90 degrees) is 1.
Plugging these numbers into the Ry matrix, we multiply Ry (matrix B) with the starting identity matrix shown in the first image (matrix A) to apply the transformation on the cube.


Taking a look at your second image, we get the correct resulting matrix.

Then, if we multiplied this matrix AB with another matrix rotating 45 degrees on the z-axis, we get the following resultant matrix.
This is in line with the result in your final image. (As for why it’s -0.8 instead of -0.7 in your image, it could be because of a floating point error, since both cos(45) and sin(45) are 1/sqrt(2), which is an irrational number that I just rounded down to 0.7).

1 Like

I’m not too familiar with Linear Algebra to be fair, just only knowing how matrices work. Thanks for the information!

Since I’m not allowed to share my university’s lecture slides, here’s an excellent video which goes over 3D affine transformation instead.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.