1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

inverse3 function

This commit is contained in:
Zeno Rogue 2020-08-08 16:05:49 +02:00
parent 4bddeedaf8
commit 191ef35d21

View File

@ -916,8 +916,7 @@ void inverse_error(const transmatrix& T) {
} }
/** inverse */ /** inverse */
EX transmatrix inverse(const transmatrix& T) { EX transmatrix inverse3(const transmatrix& T) {
if(MDIM == 3) {
ld d = det(T); ld d = det(T);
transmatrix T2; transmatrix T2;
if(d == 0) { if(d == 0) {
@ -930,6 +929,10 @@ EX transmatrix inverse(const transmatrix& T) {
T2[j][i] = (T[(i+1)%3][(j+1)%3] * T[(i+2)%3][(j+2)%3] - T[(i+1)%3][(j+2)%3] * T[(i+2)%3][(j+1)%3]) / d; T2[j][i] = (T[(i+1)%3][(j+1)%3] * T[(i+2)%3][(j+2)%3] - T[(i+1)%3][(j+2)%3] * T[(i+2)%3][(j+1)%3]) / d;
return T2; return T2;
} }
EX transmatrix inverse(const transmatrix& T) {
if(MDIM == 3)
return inverse3(T);
else { else {
transmatrix T1 = T; transmatrix T1 = T;
transmatrix T2 = Id; transmatrix T2 = Id;