summaryrefslogtreecommitdiff
path: root/common/matrix.cpp
diff options
context:
space:
mode:
authorleo2000-12-17 23:08:43 +0000
committerleo2000-12-17 23:08:43 +0000
commite679694a7bcb61ffee8351bad0396944716b81d4 (patch)
tree2ba1e9a0bc7e9ca90a82ca838114223a90c0746c /common/matrix.cpp
parent045553021e3acb4ee6d409620b5ee304d35a66f8 (diff)
Fix for rotation bug
git-svn-id: http://svn.leocad.org/trunk@182 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/matrix.cpp')
-rw-r--r--common/matrix.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/matrix.cpp b/common/matrix.cpp
index f4f1209..1af4191 100644
--- a/common/matrix.cpp
+++ b/common/matrix.cpp
@@ -421,18 +421,19 @@ void Matrix::ToEulerAngles (float *rot) const
void Matrix::ToAxisAngle (float *rot) const
{
float fTrace = m[0] + m[5] + m[10];
- float fCos = 0.5*(fTrace-1.0);
+ float inv, fCos = 0.5 * (fTrace - 1.0);
rot[3] = acos (fCos); // in [0,PI]
- if (rot[3] > 0.0)
+ if (rot[3] > 0.01f)
{
- if (rot[3] < M_PI)
+ if (fabs (M_PI - rot[3]) > 0.01f)
{
rot[0] = m[6] - m[9];
rot[1] = m[8] - m[2];
rot[2] = m[1] - m[4];
- float inv = 1.0f/(float)sqrt(rot[0]*rot[0] + rot[1]*rot[1] + rot[2]*rot[2]);
+ inv = 1.0f / (float)sqrt (rot[0]*rot[0] + rot[1]*rot[1] + rot[2]*rot[2]);
+
rot[0] *= inv;
rot[1] *= inv;
rot[2] *= inv;