To get a transformation matrix equivalent to the one you have, but reflected across a major axis you can compose it (multiply it by) a reflection matrix.
That is, if you have your input matrix M and you multiply by a matrix N that has the reflection.
To create the reflection matrix based on the major axis, you take the identity matrix and flip signs depending on the reflection you need.
You say you need to mirror the transformation on the Z axis
, I understand this as reflecting against the XY plane
. In other words, both X
and Y
values stay the same but Z
is mirrored. That means that you will flip the sign of the 1 for the Z axis
.
For clarity:
// x y z
_ _
| 1 0 0 0 |
| 0 1 0 0 |
Matrix_Mirrored_On_Z = M * | 0 0 -1 0 |
|_ 0 0 0 1 _|
Notes:
*
denotes matrix multiplication.
As said above, the shown matrix keeps X
and Y
values the same, and flips Z. If that is not what you want, I hope you can build the matrix you need using this explanation.
As you would expect, composing the reflection matrix twice should give you back the original.
I have not taken translation into consideration. The reflection matrix is intended to mirror across the XY plane
(Z = 0
). If need to mirror a translated object, you may want to undo the translation, mirror and translate again, in doing so the object will keep its location while being flipped on the Z axis
.