7#include <QtGui/qtguiglobal.h>
8#include <QtGui/qgenericmatrix.h>
9#include <QtGui/qvector3d.h>
10#include <QtGui/qvector4d.h>
15#ifndef QT_NO_QUATERNION
25 QQuaternion(
float scalar,
float xpos,
float ypos,
float zpos);
34 bool isIdentity()
const;
40 void setVector(
float x,
float y,
float z);
50 void setScalar(
float scalar);
55 float lengthSquared()
const;
76 return q1.wp == q2.wp && q1.xp == q2.xp && q1.yp == q2.yp && q1.zp == q2.zp;
100#ifndef QT_NO_VECTOR3D
104 void getAxisAndAngle(
float *
x,
float *
y,
float *
z,
float *
angle)
const;
106 (
float x,
float y,
float z,
float angle);
108#ifndef QT_NO_VECTOR3D
112 void getEulerAngles(
float *pitch,
float *yaw,
float *roll)
const;
113 static QQuaternion fromEulerAngles(
float pitch,
float yaw,
float roll);
118#ifndef QT_NO_VECTOR3D
133 float wp, xp, yp, zp;
147 return wp == 0.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f;
152 return wp == 1.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f;
168 return q1.wp * q2.wp + q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp;
174 double len = double(wp) * double(wp) +
175 double(xp) * double(xp) +
176 double(yp) * double(yp) +
177 double(zp) * double(zp);
180 float(
double(-yp) /
len),
float(
double(-zp) /
len));
218 float yy = (q1.wp - q1.yp) * (q2.wp + q2.zp);
219 float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
220 float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
221 float xx = ww + yy + zz;
222 float qq = 0.5f * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
224 float w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
225 float x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);
226 float y = qq - yy + (q1.wp - q1.xp) * (q2.yp + q2.zp);
227 float z = qq - zz + (q1.zp + q1.yp) * (q2.wp - q2.xp);
234 *
this = *
this * quaternion;
249 return QQuaternion(q1.wp + q2.wp, q1.xp + q2.xp, q1.yp + q2.yp, q1.zp + q2.zp);
254 return QQuaternion(q1.wp - q2.wp, q1.xp - q2.xp, q1.yp - q2.yp, q1.zp - q2.zp);
259 return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
264 return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor);
269 return QQuaternion(-quaternion.wp, -quaternion.xp, -quaternion.yp, -quaternion.zp);
285#ifndef QT_NO_VECTOR3D
288 : wp(aScalar), xp(aVector.
x()), yp(aVector.
y()), zp(aVector.
z()) {}
316 float pitch, yaw, roll;
335#ifndef QT_NO_VECTOR4D
338 : wp(aVector.
w()), xp(aVector.
x()), yp(aVector.
y()), zp(aVector.
z()) {}
347#ifndef QT_NO_DEBUG_STREAM
351#ifndef QT_NO_DATASTREAM
\inmodule QtCore\reentrant
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
The QQuaternion class represents a quaternion consisting of a vector and scalar.
void getEulerAngles(float *pitch, float *yaw, float *roll) const
QQuaternion conjugated() const
static QQuaternion fromEulerAngles(const QVector3D &eulerAngles)
QQuaternion & operator/=(float divisor)
Divides this quaternion's components by the given divisor, and returns a reference to this quaternion...
QQuaternion()
Constructs an identity quaternion (1, 0, 0, 0), i.e.
QQuaternion & operator-=(const QQuaternion &quaternion)
Subtracts the given quaternion from this quaternion and returns a reference to this quaternion.
QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE friend bool operator==(const QQuaternion &q1, const QQuaternion &q2) noexcept
Returns true if q1 is equal to q2; otherwise returns false.
QVector3D vector() const
Returns the vector component of this quaternion.
QQuaternion & operator+=(const QQuaternion &quaternion)
Adds the given quaternion to this quaternion and returns a reference to this quaternion.
void setVector(const QVector3D &vector)
Sets the vector component of this quaternion to vector.
bool isNull() const
Returns true if the x, y, z, and scalar components of this quaternion are set to 0....
bool isIdentity() const
Returns true if the x, y, and z components of this quaternion are set to 0.0, and the scalar componen...
float z() const
Returns the z coordinate of this quaternion's vector.
void setScalar(float scalar)
Sets the scalar component of this quaternion to scalar.
float scalar() const
Returns the scalar component of this quaternion.
QQuaternion & operator*=(float factor)
Multiplies this quaternion's components by the given factor, and returns a reference to this quaterni...
void getAxisAndAngle(QVector3D *axis, float *angle) const
void setX(float x)
Sets the x coordinate of this quaternion's vector to the given x coordinate.
QVector4D toVector4D() const
Returns this quaternion as a 4D vector.
void setZ(float z)
Sets the z coordinate of this quaternion's vector to the given z coordinate.
float x() const
Returns the x coordinate of this quaternion's vector.
float y() const
Returns the y coordinate of this quaternion's vector.
static constexpr float dotProduct(const QQuaternion &q1, const QQuaternion &q2)
void setY(float y)
Sets the y coordinate of this quaternion's vector to the given y coordinate.
friend bool operator!=(const QQuaternion &q1, const QQuaternion &q2) noexcept
Returns true if q1 is not equal to q2; otherwise returns false.
QQuaternion inverted() const
QQuaternion(Qt::Initialization)
QVector3D rotatedVector(const QVector3D &vector) const
Rotates vector with this quaternion to produce a new vector in 3D space.
QVector3D toEulerAngles() const
The QVector3D class represents a vector or vertex in 3D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr float z() const noexcept
Returns the z coordinate of this point.
The QVector4D class represents a vector or vertex in 4D space.
Combined button and popup list for selecting options.
#define QT_WARNING_DISABLE_FLOAT_COMPARE
constexpr timespec operator+(const timespec &t1, const timespec &t2)
constexpr timespec operator*(const timespec &t1, int mul)
constexpr timespec & operator+=(timespec &t1, const timespec &t2)
constexpr timespec operator-(const timespec &t1, const timespec &t2)
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
bool qFuzzyIsNull(qfloat16 f) noexcept
constexpr QMargins operator/(const QMargins &margins, int divisor)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble q
GLint GLenum GLboolean normalized
static void normalize(double &x, double &y)
const QQuaternion operator+(const QQuaternion &q1, const QQuaternion &q2)
const QQuaternion operator/(const QQuaternion &quaternion, float divisor)
bool qFuzzyCompare(const QQuaternion &q1, const QQuaternion &q2)
const QQuaternion operator*(const QQuaternion &q1, const QQuaternion &q2)
const QQuaternion operator-(const QQuaternion &q1, const QQuaternion &q2)
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QQuaternion &q)
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QQuaternion &)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)