Is there a general method to convert a matrix transformation from one coordinate system to another, so that the resulting transformation looks the same on screen?
For example, there are some transformations in a coordinate system with X right, Y up, and Z toward the viewer. And they need to be converted to a coordinate system with X right, Y away from the viewer, and Z up.
What would be the operation that needs to be performed for each matrix so that the transformations look the same in the other coordinate system? And is there a general way to construct this operation given the source and destination basis vectors?
This is a rotation around the x-axis by 90 degrees
┌ ┐
│ 1 0 0 0 │
│ 0 cos(θ) -sin(θ) 0 │
│ 0 sin(θ) cos(θ) 0 │
│ 0 0 0 1 │
└ ┘
... where cos(+/-90) = 0
, sin(+/-90) = +/-1
┌ ┐
│ 1 0 0 0 │
│ 0 0 -1 0 │
│ 0 1 0 0 │
│ 0 0 0 1 │
└ ┘
or by -90 degrees
┌ ┐
│ 1 0 0 0 │
│ 0 0 1 0 │
│ 0 -1 0 0 │
│ 0 0 0 1 │
└ ┘
I am not sure which one will help in your case. It's one of these things where, according to Murphy's law, you are doing it the wrong way round the first time.
See: 3D Transformation
To convert the transformation formulated for the old coordinate system T
into one for the new coordinate system T'
, we can write by using the above rotation R
T' = R-1 × T × R
The result is a transformation that converts a point in the new coordinate system back to the old one, then applies the original transformation and finally converts the result into the new coordinate system again.