I'm reimplementing a closed source 3d library called noesis.
It exposes a python file with all of the basic classes.
All of the implementation details are actually hidden. The implementation is compiled so I can't preview it.
I want to implement one of the fuctions from that library called mat43Inverse.
I know normally it's not possible to inverse a 4x3 matrix, but this function exists.
Sample usage from a noesis plugin:
#4x3 matrix
class NoeMat43:
# ...
def inverse(self): #returns mat43
return noesis.mat43Inverse(self)
source of exposed classes file: https://github.com/majimboo/mviewer/blob/master/noesis/plugins/python/inc_noesis.py#L478
noesis module is a compiled cpython module. (https://github.com/majimboo/mviewer/blob/master/noesis/plugins/NoesisPython.dll)
boneMtx = NoeMat43((
NoeVec3((m01, m02, m03)),
NoeVec3((m11, m12, m13)),
NoeVec3((m21, m22, m23)),
NoeVec3((m04, m14, m24))
)).inverse()
I prepared a set of correct results by calling the native function and printing the result.
input = NoeMat43((
NoeVec3((2.5, 3.6, 4.7)),
NoeVec3((2.9, 3.1, 4.3)),
NoeVec3((6.5, 7.6, 8.7)),
NoeVec3((1.1, 9.4, 3.2))
))
result = input.inverse()
expected = NoeMat43((
NoeVec3((0.04392901062965393, 0.05095765367150307, 0.1142154261469841)),
NoeVec3((0.044815145432949066, 0.038590818643569946, 0.09460975229740143)),
NoeVec3((0.04042314738035202, 0.036982882767915726, 0.07482582330703735)),
NoeVec3((-0.8928132057189941, -0.714801549911499, -0.6315471529960632))
))
noeassert('mat43Inverse', result, expected)
Correct results
1.
input: (
(1, 0, 0),
(0, 1, 0),
(0, 0, 1),
(0, 0, 0)
)
inverse result: (
(1.0, 0.0, 0.0),
(0.0, 1.0, 0.0),
(0.0, 0.0, 1.0),
(0.0, 0.0, 0.0)
)
2.
input: (
(2.5, 3.6, 4.7),
(2.9, 3.1, 4.3),
(6.5, 7.6, 8.7),
(1.1, 9.4, 3.2)
)
invserse result: (
(0.04392901062965393, 0.05095765367150307, 0.1142154261469841),
(0.044815145432949066, 0.038590818643569946, 0.09460975229740143),
(0.04042314738035202, 0.036982882767915726, 0.07482582330703735),
(-0.8928132057189941, -0.714801549911499, -0.6315471529960632)
)
3.
input: (
(0.0, 0.0, 1.0),
(0.0, 1.0, 0.0),
(-1.0, 0.0, 0.0),
(0.0, 32.29199981689453, -3.2665998935699463)
)
inverse result: (
(0.0, 0.0, -1.0),
(0.0, 1.0, 0.0),
(1.0, 0.0, 0.0),
(-3.2665998935699463, -32.29199981689453, 0.0)
)
4.
input: (
(0.0, 0.0, 2.0),
(0.0, 2.0, 0.0),
(-2.0, 0.0, 0.0),
(0.0, 32.29199981689453, -3.2665998935699463)
)
inverse result: (
(0.0, 0.0, -0.5),
(0.0, 0.5, 0.0),
(0.5, 0.0, 0.0),
(-1.6332999467849731, -16.145999908447266, 0.0)
)
5.
input: (
(2.0, 0.0, 2.0),
(0.0, 2.0, 0.0),
(-2.0, 0.0, 0.0),
(0.0, 32.29199981689453, -3.2665998935699463)
)
inverse result: (
(0.2499999850988388, 0.0, -0.2499999850988388),
(0.0, 0.5, 0.0),
(0.5, 0.0, 0.0),
(-0.8166499137878418, -16.145999908447266, 0.0)
)
Questions:
- What is the formula behind mat43Inverse function?