- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Friends

# QQuaternion Class Reference

Search for all occurrences

## Detailed Description

Definition at line 59 of file qquaternion.h.

`#include <qquaternion.h>`

List of all members.

## Public Member Functions
| QQuaternion ()
| QQuaternion (qreal scalar, qreal xpos, qreal ypos, qreal zpos)
| QQuaternion (qreal scalar, const QVector3D &vector)
| QQuaternion (const QVector4D &vector)
bool | isNull () const
bool | isIdentity () const
QVector3D | vector () const
void | setVector (const QVector3D &vector)
void | setVector (qreal x, qreal y, qreal z)
qreal | x () const
qreal | y () const
qreal | z () const
qreal | scalar () const
void | setX (qreal x)
void | setY (qreal y)
void | setZ (qreal z)
void | setScalar (qreal scalar)
qreal | length () const
qreal | lengthSquared () const
QQuaternion | normalized () const
void | normalize ()
QQuaternion | conjugate () const
QVector3D | rotatedVector (const QVector3D &vector) const
QQuaternion & | operator+= (const QQuaternion &quaternion)
QQuaternion & | operator-= (const QQuaternion &quaternion)
QQuaternion & | operator*= (qreal factor)
QQuaternion & | operator*= (const QQuaternion &quaternion)
QQuaternion & | operator/= (qreal divisor)
QVector4D | toVector4D () const
| operator QVariant () const
## Static Public Member Functions
static QQuaternion | fromAxisAndAngle (const QVector3D &axis, qreal angle)
static QQuaternion | fromAxisAndAngle (qreal x, qreal y, qreal z, qreal angle)
static QQuaternion | slerp (const QQuaternion &q1, const QQuaternion &q2, qreal t)
static QQuaternion | nlerp (const QQuaternion &q1, const QQuaternion &q2, qreal t)
## Friends
bool | operator== (const QQuaternion &q1, const QQuaternion &q2)
bool | operator!= (const QQuaternion &q1, const QQuaternion &q2)
const QQuaternion | 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 &quaternion)
const QQuaternion | operator/ (const QQuaternion &quaternion, qreal divisor)
bool | qFuzzyCompare (const QQuaternion &q1, const QQuaternion &q2)

## Constructor & Destructor Documentation

QQuaternion | ( |  | ) | `[inline]`

Definition at line 141 of file qquaternion.h.

    : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}

QQuaternion | ( | qreal | scalar,
|  | qreal | xpos,
|  | qreal | ypos,
|  | qreal | zpos
| ) |  | `[inline]`

Definition at line 143 of file qquaternion.h.

    : wp(aScalar), xp(xpos), yp(ypos), zp(zpos) {}

QQuaternion | ( | qreal | scalar,
|  | const QVector3D & | vector
| ) |  | `[inline]`

Definition at line 279 of file qquaternion.h.

        : wp(aScalar), xp(aVector.x()), yp(aVector.y()), zp(aVector.z()) {}

QQuaternion | ( | const QVector4D & | vector | ) | `[inline, explicit]`

Definition at line 305 of file qquaternion.h.

        : wp(aVector.w()), xp(aVector.x()), yp(aVector.y()), zp(aVector.z()) {}

## Member Function Documentation

bool isNull | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 146 of file qquaternion.h.

    {
        return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
    }

bool isIdentity | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 151 of file qquaternion.h.

    {
        return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && wp == 1.0f;
    }

QVector3D vector | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 289 of file qquaternion.h.

    {
        return QVector3D(xp, yp, zp);
    }

void setVector | ( | const QVector3D & | vector | ) | `[inline]`

Search for all occurrences

Definition at line 282 of file qquaternion.h.

    {
        xp = aVector.x();
        yp = aVector.y();
        zp = aVector.z();
    }

void setVector | ( | qreal | x,
|  | qreal | y,
|  | qreal | z
| ) |  | `[inline]`

Search for all occurrences

Definition at line 296 of file qquaternion.h.

    {
        xp = aX;
        yp = aY;
        zp = aZ;
    }

qreal x | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 156 of file qquaternion.h.

    { return qreal(xp); }

qreal y | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 157 of file qquaternion.h.

    { return qreal(yp); }

qreal z | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 158 of file qquaternion.h.

    { return qreal(zp); }

qreal scalar | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 159 of file qquaternion.h.

    { return qreal(wp); }

void setX | ( | qreal | x | ) | `[inline]`

Search for all occurrences

Definition at line 161 of file qquaternion.h.

    { xp = aX; }

void setY | ( | qreal | y | ) | `[inline]`

Search for all occurrences

Definition at line 162 of file qquaternion.h.

    { yp = aY; }

void setZ | ( | qreal | z | ) | `[inline]`

Search for all occurrences

Definition at line 163 of file qquaternion.h.

    { zp = aZ; }

void setScalar | ( | qreal | scalar | ) | `[inline]`

Search for all occurrences

Definition at line 164 of file qquaternion.h.

    { wp = aScalar; }

qreal length | ( |  | ) | const

Search for all occurrences

qreal lengthSquared | ( |  | ) | const

Search for all occurrences

QQuaternion normalized | ( |  | ) | const

Search for all occurrences

void normalize | ( |  | ) |

Search for all occurrences

QQuaternion conjugate | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 166 of file qquaternion.h.

    {
        return QQuaternion(wp, -xp, -yp, -zp);
    }

QVector3D rotatedVector | ( | const QVector3D & | vector | ) | const

Search for all occurrences

QQuaternion & operator+= | ( | const QQuaternion & | quaternion | ) | `[inline]`

Definition at line 171 of file qquaternion.h.

    {
        xp += quaternion.xp;
        yp += quaternion.yp;
        zp += quaternion.zp;
        wp += quaternion.wp;
        return *this;
    }

QQuaternion & operator-= | ( | const QQuaternion & | quaternion | ) | `[inline]`

Definition at line 180 of file qquaternion.h.

    {
        xp -= quaternion.xp;
        yp -= quaternion.yp;
        zp -= quaternion.zp;
        wp -= quaternion.wp;
        return *this;
    }

QQuaternion & operator*= | ( | qreal | factor | ) | `[inline]`

Definition at line 189 of file qquaternion.h.

    {
        xp *= factor;
        yp *= factor;
        zp *= factor;
        wp *= factor;
        return *this;
    }

QQuaternion & operator*= | ( | const QQuaternion & | quaternion | ) | `[inline]`

Definition at line 214 of file qquaternion.h.

    {
        *this = *this * quaternion;
        return *this;
    }

QQuaternion & operator/= | ( | qreal | divisor | ) | `[inline]`

Definition at line 220 of file qquaternion.h.

    {
        xp /= divisor;
        yp /= divisor;
        zp /= divisor;
        wp /= divisor;
        return *this;
    }

QVector4D toVector4D | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 308 of file qquaternion.h.

    {
        return QVector4D(xp, yp, zp, wp);
    }

operator QVariant | ( |  | ) | const

static QQuaternion fromAxisAndAngle | ( | const QVector3D & | axis,
|  | qreal | angle
| ) |  | `[static]`

Search for all occurrences

static QQuaternion fromAxisAndAngle | ( | qreal | x,
|  | qreal | y,
|  | qreal | z,
|  | qreal | angle
| ) |  | `[static]`

Search for all occurrences

static QQuaternion slerp | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2,
|  | qreal | t
| ) |  | `[static]`

Search for all occurrences

static QQuaternion nlerp | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2,
|  | qreal | t
| ) |  | `[static]`

Search for all occurrences

## Friends And Related Function Documentation

bool operator== | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2
| ) |  | `[friend]`

Definition at line 229 of file qquaternion.h.

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

bool operator!= | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2
| ) |  | `[friend]`

Definition at line 234 of file qquaternion.h.

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

const QQuaternion operator+ | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2
| ) |  | `[friend]`

Definition at line 239 of file qquaternion.h.

    {
        return QQuaternion(q1.wp + q2.wp, q1.xp + q2.xp, q1.yp + q2.yp, q1.zp + q2.zp);
    }

const QQuaternion operator- | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2
| ) |  | `[friend]`

Definition at line 244 of file qquaternion.h.

    {
        return QQuaternion(q1.wp - q2.wp, q1.xp - q2.xp, q1.yp - q2.yp, q1.zp - q2.zp);
    }

const QQuaternion operator* | ( | qreal | factor,
|  | const QQuaternion & | quaternion
| ) |  | `[friend]`

Definition at line 249 of file qquaternion.h.

    {
        return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
    }

const QQuaternion operator* | ( | const QQuaternion & | quaternion,
|  | qreal | factor
| ) |  | `[friend]`

Definition at line 254 of file qquaternion.h.

    {
        return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
    }

const QQuaternion operator* | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2
| ) |  | `[friend]`

Definition at line 198 of file qquaternion.h.

    {
        qreal ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
        qreal yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
        qreal zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
        qreal xx = ww + yy + zz;
        qreal qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));

        qreal w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
        qreal x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);
        qreal y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp);
        qreal z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp);

        return QQuaternion(w, x, y, z);
    }

const QQuaternion operator- | ( | const QQuaternion & | quaternion | ) | `[friend]`

Definition at line 259 of file qquaternion.h.

    {
        return QQuaternion(-quaternion.wp, -quaternion.xp, -quaternion.yp, -quaternion.zp);
    }

const QQuaternion operator/ | ( | const QQuaternion & | quaternion,
|  | qreal | divisor
| ) |  | `[friend]`

Definition at line 264 of file qquaternion.h.

    {
        return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor);
    }

bool qFuzzyCompare | ( | const QQuaternion & | q1,
|  | const QQuaternion & | q2
| ) |  | `[friend]`

Search for all occurrences

Definition at line 269 of file qquaternion.h.

    {
        return qFuzzyCompare(q1.xp, q2.xp) &&
               qFuzzyCompare(q1.yp, q2.yp) &&
               qFuzzyCompare(q1.zp, q2.zp) &&
               qFuzzyCompare(q1.wp, q2.wp);
    }

The documentation for this class was generated from the following file:

- QtGui/qquaternion.h

QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion
QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion QQuaternion