diff options
author | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2013-01-29 02:34:32 +0100 |
---|---|---|
committer | Wolfgang Draxinger <Wolfgang.Draxinger@draxit.de> | 2013-01-29 02:34:32 +0100 |
commit | 5fe28a331f492dab25c300d5d3e63c68eee51b9f (patch) | |
tree | 7022dcb0a26fd03aaba09b03d8efd906ca59758b | |
parent | 0a7b1afb5f0835013d5aa201f1c0fc8707afff53 (diff) | |
download | linmath-5fe28a331f492dab25c300d5d3e63c68eee51b9f.tar.gz linmath-5fe28a331f492dab25c300d5d3e63c68eee51b9f.tar.xz linmath-5fe28a331f492dab25c300d5d3e63c68eee51b9f.zip |
minor fix in quat_from_mat4x4 with huge impact
-rw-r--r-- | linmath.h | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 |