
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQQuaternion class represents a quaternion consisting of a vector and scalar.More...
| Header: | #include <QQuaternion> |
| Since: | Qt 4.6 |
| QQuaternion() | |
| QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos) | |
| QQuaternion(qreal scalar, const QVector3D & vector) | |
| QQuaternion(const QVector4D & vector) | |
| QQuaternion | conjugate() const |
| bool | isIdentity() const |
| bool | isNull() const |
| qreal | length() const |
| qreal | lengthSquared() const |
| void | normalize() |
| QQuaternion | normalized() const |
| QVector3D | rotatedVector(const QVector3D & vector) const |
| qreal | scalar() const |
| void | setScalar(qreal scalar) |
| void | setVector(const QVector3D & vector) |
| void | setVector(qreal x, qreal y, qreal z) |
| void | setX(qreal x) |
| void | setY(qreal y) |
| void | setZ(qreal z) |
| QVector4D | toVector4D() const |
| QVector3D | vector() const |
| qreal | x() const |
| qreal | y() const |
| qreal | z() const |
| operator QVariant() const | |
| QQuaternion & | operator*=(qreal factor) |
| QQuaternion & | operator*=(const QQuaternion & quaternion) |
| QQuaternion & | operator+=(const QQuaternion & quaternion) |
| QQuaternion & | operator-=(const QQuaternion & quaternion) |
| QQuaternion & | operator/=(qreal divisor) |
| QQuaternion | fromAxisAndAngle(const QVector3D & axis, qreal angle) |
| QQuaternion | fromAxisAndAngle(qreal x, qreal y, qreal z, qreal angle) |
| QQuaternion | nlerp(const QQuaternion & q1, const QQuaternion & q2, qreal t) |
| QQuaternion | slerp(const QQuaternion & q1, const QQuaternion & q2, qreal t) |
| bool | qFuzzyCompare(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*(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) |
| QDataStream & | operator<<(QDataStream & stream, const QQuaternion & quaternion) |
| bool | operator==(const QQuaternion & q1, const QQuaternion & q2) |
| QDataStream & | operator>>(QDataStream & stream, QQuaternion & quaternion) |
| QDataStream & | operator>>(QDataStream & stream, QEasingCurve & easing) |
TheQQuaternion class represents a quaternion consisting of a vector and scalar.
Quaternions are used to represent rotations in 3D space, and consist of a 3D rotation axis specified by the x, y, and z coordinates, and a scalar representing the rotation angle.
Constructs an identity quaternion, i.e. with coordinates (1, 0, 0, 0).
Constructs a quaternion with the vector (xpos,ypos,zpos) andscalar.
Constructs a quaternion vector from the specifiedvector andscalar.
Constructs a quaternion from the components ofvector.
Returns the conjugate of this quaternion, which is (-x, -y, -z, scalar).
[static]QQuaternion QQuaternion::fromAxisAndAngle(constQVector3D & axis,qreal angle)Creates a normalized quaternion that corresponds to rotating throughangle degrees about the specified 3Daxis.
[static]QQuaternion QQuaternion::fromAxisAndAngle(qreal x,qreal y,qreal z,qreal angle)Creates a normalized quaternion that corresponds to rotating throughangle degrees about the 3D axis (x,y,z).
Returns true if the x, y, and z components of this quaternion are set to 0.0, and the scalar component is set to 1.0; otherwise returns false.
Returns true if the x, y, z, and scalar components of this quaternion are set to 0.0; otherwise returns false.
Returns the length of the quaternion. This is also called the "norm".
See alsolengthSquared() andnormalized().
Returns the squared length of the quaternion.
See alsolength().
[static]QQuaternion QQuaternion::nlerp(constQQuaternion & q1, constQQuaternion & q2,qreal t)Interpolates along the shortest linear path between the rotational positionsq1 andq2. The valuet should be between 0 and 1, indicating the distance to travel betweenq1 andq2. The result will benormalized().
Ift is less than or equal to 0, thenq1 will be returned. Ift is greater than or equal to 1, thenq2 will be returned.
The nlerp() function is typically faster thanslerp() and will give approximate results to spherical interpolation that are good enough for some applications.
See alsoslerp().
Normalizes the currect quaternion in place. Nothing happens if this is a null quaternion or the length of the quaternion is very close to 1.
See alsolength() andnormalized().
Returns the normalized unit form of this quaternion.
If this quaternion is null, then a null quaternion is returned. If the length of the quaternion is very close to 1, then the quaternion will be returned as-is. Otherwise the normalized form of the quaternion of length 1 will be returned.
See alsolength() andnormalize().
Rotatesvector with this quaternion to produce a new vector in 3D space. The following code:
QVector3D result= q.rotatedVector(vector);
is equivalent to the following:
QVector3D result= (q*QQuaternion(0, vector)* q.conjugate()).vector();
Returns the scalar component of this quaternion.
See alsosetScalar(),x(),y(), andz().
Sets the scalar component of this quaternion toscalar.
See alsoscalar(),setX(),setY(), andsetZ().
Sets the vector component of this quaternion tovector.
See alsovector() andsetScalar().
Sets the vector component of this quaternion to (x,y,z).
See alsovector() andsetScalar().
Sets the x coordinate of this quaternion's vector to the givenx coordinate.
See alsox(),setY(),setZ(), andsetScalar().
Sets the y coordinate of this quaternion's vector to the giveny coordinate.
See alsoy(),setX(),setZ(), andsetScalar().
Sets the z coordinate of this quaternion's vector to the givenz coordinate.
See alsoz(),setX(),setY(), andsetScalar().
[static]QQuaternion QQuaternion::slerp(constQQuaternion & q1, constQQuaternion & q2,qreal t)Interpolates along the shortest spherical path between the rotational positionsq1 andq2. The valuet should be between 0 and 1, indicating the spherical distance to travel betweenq1 andq2.
Ift is less than or equal to 0, thenq1 will be returned. Ift is greater than or equal to 1, thenq2 will be returned.
See alsonlerp().
Returns this quaternion as a 4D vector.
Returns the vector component of this quaternion.
See alsosetVector() andscalar().
Returns the x coordinate of this quaternion's vector.
See alsosetX(),y(),z(), andscalar().
Returns the y coordinate of this quaternion's vector.
See alsosetY(),x(),z(), andscalar().
Returns the z coordinate of this quaternion's vector.
See alsosetZ(),x(),y(), andscalar().
Returns the quaternion as aQVariant.
Multiplies this quaternion's components by the givenfactor, and returns a reference to this quaternion.
See alsooperator/=().
Multiplies this quaternion byquaternion and returns a reference to this quaternion.
Adds the givenquaternion to this quaternion and returns a reference to this quaternion.
See alsooperator-=().
Subtracts the givenquaternion from this quaternion and returns a reference to this quaternion.
See alsooperator+=().
Divides this quaternion's components by the givendivisor, and returns a reference to this quaternion.
See alsooperator*=().
Returns true ifq1 andq2 are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.
Returns true ifq1 is not equal toq2; otherwise returns false. This operator uses an exact floating-point comparison.
Multipliesq1 andq2 using quaternion multiplication. The result corresponds to applying both of the rotations specified byq1 andq2.
See alsoQQuaternion::operator*=().
Returns a copy of the givenquaternion, multiplied by the givenfactor.
See alsoQQuaternion::operator*=().
Returns a copy of the givenquaternion, multiplied by the givenfactor.
See alsoQQuaternion::operator*=().
Returns aQQuaternion object that is the sum of the given quaternions,q1 andq2; each component is added separately.
See alsoQQuaternion::operator+=().
Returns aQQuaternion object that is formed by subtractingq2 fromq1; each component is subtracted separately.
See alsoQQuaternion::operator-=().
This is an overloaded function.
Returns aQQuaternion object that is formed by changing the sign of all three components of the givenquaternion.
Equivalent toQQuaternion(0,0,0,0) - quaternion.
Returns theQQuaternion object formed by dividing all components of the givenquaternion by the givendivisor.
See alsoQQuaternion::operator/=().
Writes the givenquaternion to the givenstream and returns a reference to the stream.
See alsoSerializing Qt Data Types.
Returns true ifq1 is equal toq2; otherwise returns false. This operator uses an exact floating-point comparison.
Reads a quaternion from the givenstream into the givenquaternion and returns a reference to the stream.
See alsoSerializing Qt Data Types.
Reads an easing curve from the givenstream into the giveneasing curve and returns a reference to the stream.
See alsoSerializing Qt Data Types.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.