0

I'm producing three vectors like so:

Vector aXDir=Matrix.Multiply(Vector(1,0,0));
Vector aYDir=Matrix.Multiply(Vector(0,1,0));
Vector aZDir=Matrix.Multiply(Vector(0,0,1));

But later, I want to use these vectors to re-assemble the original matrix. I originally thought I could multiply three lookat matrices, but alas, unless only one axis is rotated, the values accumulate and I get an exaggerated version of the original matrix.

It's a rotation-only matrix, no translate.

Is there any way to backwards engineer my old matrix from these three vectors?

[Edit] I did try combining the three directional vectors and then producing matrix looking at the combined result. This also produced incorrect results for me.

KiraHoneybee
  • 495
  • 3
  • 12
  • 1
    Depends on what operations your `Matrix` class provides. Those three vectors are simply three columns of a matrix; if nothing else, you should be able to copy them into a new matrix element by element (and for that matter, copy them out of the original matrix; I imagine that would be faster than general-purpose multiplication). – Igor Tandetnik May 22 '22 at 02:28
  • 1
    see [Understanding 4x4 homogenous transform matrices](https://stackoverflow.com/a/28084380/2521214) for the layout where to copy the vectors ... if you have just 3x3 rotation matrix then just ignore the last row and column in the 4x4 matrix layout ... just take in mind to use your conventions those in that answer refers to default OpenGL ... – Spektre May 22 '22 at 05:44
  • Spektre, I was able it figure it out from your comment. If you want to post this as an answer, I will hit the checkmark. – KiraHoneybee May 22 '22 at 11:47
  • @KiraHoneybee its too simple for an answer and creating more robust one would lead to somewhat duplicate of that link ... – Spektre May 22 '22 at 18:16

0 Answers0