From 5d784deb71edd1e6584cd2f118d27dd3be2da5e6 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 9 Feb 2015 17:50:25 +0400 Subject: [QQuaternion] Introduce toAxisAndAngle() This operation is the exact opposite to QQuaternion::fromAxisAndAngle() (so that it is a way to extract the axis and angle values suitable to create the same quaternion via QQuaternion::fromAxisAndAngle()). Change-Id: I41fda58f5fb2b867cccd6b2faf58ab671fa070da Reviewed-by: Laszlo Agocs --- src/gui/math3d/qquaternion.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gui/math3d/qquaternion.h') diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index d4ad3df597..eb835ef806 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -115,8 +115,10 @@ public: operator QVariant() const; #ifndef QT_NO_VECTOR3D + inline void toAxisAndAngle(QVector3D *axis, float *angle) const; static QQuaternion fromAxisAndAngle(const QVector3D& axis, float angle); #endif + void toAxisAndAngle(float *x, float *y, float *z, float *angle) const; static QQuaternion fromAxisAndAngle (float x, float y, float z, float angle); @@ -299,6 +301,13 @@ inline QVector3D QQuaternion::vector() const return QVector3D(xp, yp, zp); } +inline void QQuaternion::toAxisAndAngle(QVector3D *axis, float *angle) const +{ + float aX, aY, aZ; + toAxisAndAngle(&aX, &aY, &aZ, angle); + *axis = QVector3D(aX, aY, aZ); +} + #endif inline void QQuaternion::setVector(float aX, float aY, float aZ) -- cgit v1.2.3