summaryrefslogtreecommitdiffstats
path: root/src/gui/math3d/qquaternion.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-04 08:14:34 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-04 08:14:34 (GMT)
commit57e75716ac3eb47ca2d801e116a6b12a200c8808 (patch)
tree4ae57782c40e90cf2ada92156f660975bad6c1a4 /src/gui/math3d/qquaternion.cpp
parent807d129265b05e0f5e575e126e97078d96b16242 (diff)
parentbd07aa3419be10cffee2d9eba359dd25fbdb11f2 (diff)
downloadQt-57e75716ac3eb47ca2d801e116a6b12a200c8808.zip
Qt-57e75716ac3eb47ca2d801e116a6b12a200c8808.tar.gz
Qt-57e75716ac3eb47ca2d801e116a6b12a200c8808.tar.bz2
Merge branch '4.6' of git@scm.dev.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/gui/math3d/qquaternion.cpp')
-rw-r--r--src/gui/math3d/qquaternion.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index ece4482..7206e9a 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -353,7 +353,7 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
qreal s = qSin(a);
qreal c = qCos(a);
QVector3D ax = axis.normalized();
- return QQuaternion(c, ax.xp * s, ax.yp * s, ax.zp * s, 1).normalized();
+ return QQuaternion(c, ax.x() * s, ax.y() * s, ax.z() * s).normalized();
}
#endif
@@ -365,19 +365,16 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
QQuaternion QQuaternion::fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle)
{
- float xp = x;
- float yp = y;
- float zp = z;
- qreal length = qSqrt(xp * xp + yp * yp + zp * zp);
- if (!qIsNull(length)) {
- xp /= length;
- yp /= length;
- zp /= length;
+ qreal length = qSqrt(x * x + y * y + z * z);
+ if (!qFuzzyIsNull(length - 1.0f) && !qFuzzyIsNull(length)) {
+ x /= length;
+ y /= length;
+ z /= length;
}
qreal a = (angle / 2.0f) * M_PI / 180.0f;
qreal s = qSin(a);
qreal c = qCos(a);
- return QQuaternion(c, xp * s, yp * s, zp * s, 1).normalized();
+ return QQuaternion(c, x * s, y * s, z * s).normalized();
}
/*!