[Closed] Right or Left handed matrix?
OK so I have worked out how to get if a matrix is right or left handed but I just want to pass it by people here to make sure that I’m not missing something dumb.
acos (dot (cross vx vy ) vz)
This will return either 0 for a right handed matrix or 180 for a left handed. From what I can see I don’t have to check the other vector combinations because they all should return the same. So either all are 0 or all are 180.
Does this hold true? Assuming all vectors are normalized and taking into account max’s single precision. I do get values that are not 180 in some cases but 179.98:(
I use the same thing in my Doom3’s model exporter (and other exporters of mine) to know if a node (a bone in this case) has been mirrored (left handed transformation matrix) o not (right handed transformation matrix). In my case I don’t use the acos function. So:
dot (cross node.transform.row1 node.transform.row2) node.transform.row3 > 0
If this sentence returns true means the node has a right handed matrix transformation, that is, the cosine of the angle between the two vectors is greater than 0 (90º). Otherwise, it is a left handed matrix. Of course, as you said, the result of the dot product should be 1 (0º) for the right handed transformation or -1 (180º) for the left handed one. That's because the transformation matrix should be orthonormal, that is, the 3 basis vectors form a right angle each other. But as you stated, because of the maxscript's single precission, that could not be the case. That's the reason why I use the "greater than" comparison instead of a comparison with a fixed value (1 or -1).
Until now this method has worked fine for me.
Best regards.
Thanks for getting back to me. I didn’t even think about dropping the acos as it isn’t needed. Glad that you are using the same basic method, good to know that I hit the mark and wasn’t way off.
I’ll rip out the acos as Im sure that would be slowing it down.