aboutsummaryrefslogtreecommitdiffstats
path: root/linmath.h
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-01-29 02:34:32 +0100
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-01-29 02:34:32 +0100
commit5fe28a331f492dab25c300d5d3e63c68eee51b9f (patch)
tree7022dcb0a26fd03aaba09b03d8efd906ca59758b /linmath.h
parent0a7b1afb5f0835013d5aa201f1c0fc8707afff53 (diff)
downloadlinmath-5fe28a331f492dab25c300d5d3e63c68eee51b9f.tar.gz
linmath-5fe28a331f492dab25c300d5d3e63c68eee51b9f.tar.xz
linmath-5fe28a331f492dab25c300d5d3e63c68eee51b9f.zip
minor fix in quat_from_mat4x4 with huge impact
Diffstat (limited to 'linmath.h')
-rw-r--r--linmath.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/linmath.h b/linmath.h
index 1a87ca9..deb5837 100644
--- a/linmath.h
+++ b/linmath.h
@@ -440,14 +440,15 @@ static inline void quat_from_mat4x4(quat q, mat4x4 M)
r = sqrtf(1. + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]] );
if(r < 1e-6) {
- mat4x4_identity(M);
+ q[0] = 1.;
+ q[1] = q[2] = q[3] = 0.;
return;
}
- q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.*r);
q[0] = r/2.;
q[1] = (M[p[0]][p[1]] - M[p[1]][p[0]])/(2.*r);
q[2] = (M[p[2]][p[0]] - M[p[0]][p[2]])/(2.*r);
+ q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.*r);
}
#endif