Qt 4.8
Classes | Functions
qquaternion.h File Reference
#include <QtGui/qvector3d.h>
#include <QtGui/qvector4d.h>

Go to the source code of this file.

Classes

class  QQuaternion
 The QQuaternion class represents a quaternion consisting of a vector and scalar. More...
 

Functions

bool operator!= (const QQuaternion &q1, const QQuaternion &q2)
 
const QQuaternion operator* (const QQuaternion &q1, const QQuaternion &q2)
 
const QQuaternion operator* (qreal factor, const QQuaternion &quaternion)
 
const QQuaternion operator* (const QQuaternion &quaternion, qreal factor)
 
const QQuaternion operator+ (const QQuaternion &q1, const QQuaternion &q2)
 
const QQuaternion operator- (const QQuaternion &q1, const QQuaternion &q2)
 
const QQuaternion operator- (const QQuaternion &quaternion)
 
const QQuaternion operator/ (const QQuaternion &quaternion, qreal divisor)
 
Q_GUI_EXPORT QDebug operator<< (QDebug dbg, const QQuaternion &q)
 
Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QQuaternion &)
 
bool operator== (const QQuaternion &q1, const QQuaternion &q2)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QQuaternion &)
 
 Q_DECLARE_TYPEINFO (QQuaternion, Q_MOVABLE_TYPE)
 
bool qFuzzyCompare (const QQuaternion &q1, const QQuaternion &q2)
 

Function Documentation

◆ operator!=()

bool operator!= ( const QQuaternion q1,
const QQuaternion q2 
)
inline

Definition at line 234 of file qquaternion.h.

235 {
236  return q1.xp != q2.xp || q1.yp != q2.yp || q1.zp != q2.zp || q1.wp != q2.wp;
237 }

◆ operator*() [1/3]

const QQuaternion operator* ( const QQuaternion q1,
const QQuaternion q2 
)
inline

Definition at line 198 of file qquaternion.h.

199 {
200  qreal ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
201  qreal yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
202  qreal zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
203  qreal xx = ww + yy + zz;
204  qreal qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
205 
206  qreal w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
207  qreal x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);
208  qreal y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp);
209  qreal z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp);
210 
211  return QQuaternion(w, x, y, z);
212 }
double qreal
Definition: qglobal.h:1193
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59

◆ operator*() [2/3]

const QQuaternion operator* ( qreal  factor,
const QQuaternion quaternion 
)
inline

Definition at line 249 of file qquaternion.h.

250 {
251  return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
252 }
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59

◆ operator*() [3/3]

const QQuaternion operator* ( const QQuaternion quaternion,
qreal  factor 
)
inline

Definition at line 254 of file qquaternion.h.

255 {
256  return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
257 }
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59

◆ operator+()

const QQuaternion operator+ ( const QQuaternion q1,
const QQuaternion q2 
)
inline

Definition at line 239 of file qquaternion.h.

240 {
241  return QQuaternion(q1.wp + q2.wp, q1.xp + q2.xp, q1.yp + q2.yp, q1.zp + q2.zp);
242 }
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59

◆ operator-() [1/2]

const QQuaternion operator- ( const QQuaternion q1,
const QQuaternion q2 
)
inline

Definition at line 244 of file qquaternion.h.

245 {
246  return QQuaternion(q1.wp - q2.wp, q1.xp - q2.xp, q1.yp - q2.yp, q1.zp - q2.zp);
247 }
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59

◆ operator-() [2/2]

const QQuaternion operator- ( const QQuaternion quaternion)
inline

Definition at line 259 of file qquaternion.h.

260 {
261  return QQuaternion(-quaternion.wp, -quaternion.xp, -quaternion.yp, -quaternion.zp);
262 }
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59

◆ operator/()

const QQuaternion operator/ ( const QQuaternion quaternion,
qreal  divisor 
)
inline

Definition at line 264 of file qquaternion.h.

265 {
266  return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor);
267 }
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59

◆ operator<<() [1/2]

Q_GUI_EXPORT QDebug operator<< ( QDebug  dbg,
const QQuaternion q 
)

Definition at line 666 of file qquaternion.cpp.

667 {
668  dbg.nospace() << "QQuaternion(scalar:" << q.scalar()
669  << ", vector:(" << q.x() << ", "
670  << q.y() << ", " << q.z() << "))";
671  return dbg.space();
672 }
qreal x() const
Returns the x coordinate of this quaternion&#39;s vector.
Definition: qquaternion.h:156
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
qreal scalar() const
Returns the scalar component of this quaternion.
Definition: qquaternion.h:159
qreal y() const
Returns the y coordinate of this quaternion&#39;s vector.
Definition: qquaternion.h:157
qreal z() const
Returns the z coordinate of this quaternion&#39;s vector.
Definition: qquaternion.h:158
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91

◆ operator<<() [2/2]

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream ,
const QQuaternion  
)
related

Definition at line 691 of file qquaternion.cpp.

692 {
693  stream << double(quaternion.scalar()) << double(quaternion.x())
694  << double(quaternion.y()) << double(quaternion.z());
695  return stream;
696 }
static FILE * stream

◆ operator==()

bool operator== ( const QQuaternion q1,
const QQuaternion q2 
)
inline

Definition at line 229 of file qquaternion.h.

230 {
231  return q1.xp == q2.xp && q1.yp == q2.yp && q1.zp == q2.zp && q1.wp == q2.wp;
232 }

◆ operator>>()

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream ,
QQuaternion  
)
related

Definition at line 711 of file qquaternion.cpp.

712 {
713  double scalar, x, y, z;
714  stream >> scalar;
715  stream >> x;
716  stream >> y;
717  stream >> z;
718  quaternion.setScalar(qreal(scalar));
719  quaternion.setX(qreal(x));
720  quaternion.setY(qreal(y));
721  quaternion.setZ(qreal(z));
722  return stream;
723 }
double qreal
Definition: qglobal.h:1193
static FILE * stream

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( QQuaternion  ,
Q_MOVABLE_TYPE   
)

◆ qFuzzyCompare()

bool qFuzzyCompare ( const QQuaternion q1,
const QQuaternion q2 
)
inline

Definition at line 269 of file qquaternion.h.

270 {
271  return qFuzzyCompare(q1.xp, q2.xp) &&
272  qFuzzyCompare(q1.yp, q2.yp) &&
273  qFuzzyCompare(q1.zp, q2.zp) &&
274  qFuzzyCompare(q1.wp, q2.wp);
275 }
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
The qFuzzyCompare function is for comparing two matrices using a fuzziness factor.
Definition: qmatrix.h:172