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?
CodePudding user response:
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
CodePudding user response:
There is an excellent open source library that you might want to look at: https://github.com/mathnet/mathnet-spatial https://spatial.mathdotnet.com/api/MathNet.Spatial.Euclidean/CoordinateSystem.htm
CodePudding user response:
You just need to compose that matrix that does something you like with the appropriate coordinate transformation matrices. If you have a system A and some operation X on pts in that system you like, but you encode your points in system B for the same space and want to do what X does in space, then you can just apply X'=inv(M)XM where M is the coordinate transformation from B to A.