1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
hstructure Matrix33
_11 : number
_12 : number
_13 : number
_21 : number
_22 : number
_23 : number
_31 : number
_32 : number
_33 : number
end
end
end
end
end
local inverseDeterminant = 1 / determinant
-- store values in locals so we can reuse m as our result matrix: this way we aren't editing the input as we record our output
result . _11 = _11
result . _12 = _12
result . _13 = _13
result . _21 = _21
result . _22 = _22
result . _23 = _23
result . _31 = _31
result . _32 = _32
result . _33 = _33
end
-- store values in locals so we can reuse a or b as our result matrix: this way we aren't editing the input as we record our output
local _11 = a . _11 * b . _11 + a . _12 * b . _21 + a . _13 * b . _31
local _12 = a . _11 * b . _12 + a . _12 * b . _22 + a . _13 * b . _32
local _13 = a . _11 * b . _13 + a . _12 * b . _23 + a . _13 * b . _33
local _21 = a . _21 * b . _11 + a . _22 * b . _21 + a . _23 * b . _31
local _22 = a . _21 * b . _12 + a . _22 * b . _22 + a . _23 * b . _32
local _23 = a . _21 * b . _13 + a . _22 * b . _23 + a . _23 * b . _33
local _31 = a . _31 * b . _11 + a . _32 * b . _21 + a . _33 * b . _31
local _32 = a . _31 * b . _12 + a . _32 * b . _22 + a . _33 * b . _32
local _33 = a . _31 * b . _13 + a . _32 * b . _23 + a . _33 * b . _33
result . _11 = _11
result . _12 = _12
result . _13 = _13
result . _21 = _21
result . _22 = _22
result . _23 = _23
result . _31 = _31
result . _32 = _32
result . _33 = _33
end
return outX , outY
end |