QQuaternion 类

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

头: #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 )

详细描述

The QQuaternion 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.

成员函数文档编制

QQuaternion:: QQuaternion ()

Constructs an identity quaternion, i.e. with coordinates (1, 0, 0, 0).

QQuaternion:: QQuaternion ( qreal scalar , qreal xpos , qreal ypos , qreal zpos )

Constructs a quaternion with the vector ( xpos , ypos , zpos ) 和 scalar .

QQuaternion:: QQuaternion ( qreal scalar , const QVector3D & vector )

Constructs a quaternion vector from the specified vector and scalar .

另请参阅 vector () 和 scalar ().

QQuaternion:: QQuaternion (const QVector4D & vector )

构造四元数从分量为 vector .

QQuaternion QQuaternion:: conjugate () const

Returns the conjugate of this quaternion, which is (-x, -y, -z, scalar).

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

Creates a normalized quaternion that corresponds to rotating through angle degrees about the specified 3D axis .

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

Creates a normalized quaternion that corresponds to rotating through angle degrees about the 3D axis ( x , y , z ).

bool QQuaternion:: isIdentity () const

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.

bool QQuaternion:: isNull () const

Returns true if the x, y, z, and scalar components of this quaternion are set to 0.0; otherwise returns false.

qreal QQuaternion:: length () const

Returns the length of the quaternion. This is also called the "norm".

另请参阅 lengthSquared () 和 normalized ().

qreal QQuaternion:: lengthSquared () const

Returns the squared length of the quaternion.

另请参阅 length ().

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

Interpolates along the shortest linear path between the rotational positions q1 and q2 。值 t should be between 0 and 1, indicating the distance to travel between q1 and q2 . The result will be normalized ().

t is less than or equal to 0, then q1 will be returned. If t is greater than or equal to 1, then q2 将被返回。

The nlerp() function is typically faster than slerp () and will give approximate results to spherical interpolation that are good enough for some applications.

另请参阅 slerp ().

void QQuaternion:: normalize ()

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.

另请参阅 length () 和 normalized ().

QQuaternion QQuaternion:: normalized () const

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.

另请参阅 length () 和 normalize ().

QVector3D QQuaternion:: rotatedVector (const QVector3D & vector ) const

Rotates vector with this quaternion to produce a new vector in 3D space. The following code:

QVector3D result = q.rotatedVector(vector);
					

相当于以下:

QVector3D result = (q * QQuaternion(0, vector) * q.conjugate()).vector();
					

qreal QQuaternion:: scalar () const

Returns the scalar component of this quaternion.

另请参阅 setScalar (), x (), y (),和 z ().

void QQuaternion:: setScalar ( qreal scalar )

Sets the scalar component of this quaternion to scalar .

另请参阅 scalar (), setX (), setY (),和 setZ ().

void QQuaternion:: setVector (const QVector3D & vector )

Sets the vector component of this quaternion to vector .

另请参阅 vector () 和 setScalar ().

void QQuaternion:: setVector ( qreal x , qreal y , qreal z )

Sets the vector component of this quaternion to ( x , y , z ).

另请参阅 vector () 和 setScalar ().

void QQuaternion:: setX ( qreal x )

Sets the x coordinate of this quaternion's vector to the given x 坐标。

另请参阅 x (), setY (), setZ (),和 setScalar ().

void QQuaternion:: setY ( qreal y )

Sets the y coordinate of this quaternion's vector to the given y 坐标。

另请参阅 y (), setX (), setZ (),和 setScalar ().

void QQuaternion:: setZ ( qreal z )

Sets the z coordinate of this quaternion's vector to the given z 坐标。

另请参阅 z (), setX (), setY (),和 setScalar ().

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

Interpolates along the shortest spherical path between the rotational positions q1 and q2 。值 t should be between 0 and 1, indicating the spherical distance to travel between q1 and q2 .

t is less than or equal to 0, then q1 will be returned. If t is greater than or equal to 1, then q2 将被返回。

另请参阅 nlerp ().

QVector4D QQuaternion:: toVector4D () const

Returns this quaternion as a 4D vector.

QVector3D QQuaternion:: vector () const

Returns the vector component of this quaternion.

另请参阅 setVector () 和 scalar ().

qreal QQuaternion:: x () const

Returns the x coordinate of this quaternion's vector.

另请参阅 setX (), y (), z (),和 scalar ().

qreal QQuaternion:: y () const

Returns the y coordinate of this quaternion's vector.

另请参阅 setY (), x (), z (),和 scalar ().

qreal QQuaternion:: z () const

Returns the z coordinate of this quaternion's vector.

另请参阅 setZ (), x (), y (),和 scalar ().

QQuaternion:: operator QVariant () const

Returns the quaternion as a QVariant .

QQuaternion & QQuaternion:: operator*= ( qreal factor )

Multiplies this quaternion's components by the given factor , and returns a reference to this quaternion.

另请参阅 operator/= ().

QQuaternion & QQuaternion:: operator*= (const QQuaternion & quaternion )

Multiplies this quaternion by quaternion and returns a reference to this quaternion.

QQuaternion & QQuaternion:: operator+= (const QQuaternion & quaternion )

添加给定 quaternion to this quaternion and returns a reference to this quaternion.

另请参阅 operator-= ().

QQuaternion & QQuaternion:: operator-= (const QQuaternion & quaternion )

减去给定 quaternion from this quaternion and returns a reference to this quaternion.

另请参阅 operator+= ().

QQuaternion & QQuaternion:: operator/= ( qreal divisor )

Divides this quaternion's components by the given divisor , and returns a reference to this quaternion.

另请参阅 operator*= ().

相关非成员

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

返回 true 若 q1 and q2 are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.

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

返回 true 若 q1 不等于 q2 ; otherwise returns false. This operator uses an exact floating-point comparison.

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

Multiplies q1 and q2 using quaternion multiplication. The result corresponds to applying both of the rotations specified by q1 and q2 .

另请参阅 QQuaternion::operator*= ().

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

返回副本为给定 quaternion ,乘以给定 factor .

另请参阅 QQuaternion::operator*= ().

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

返回副本为给定 quaternion ,乘以给定 factor .

另请参阅 QQuaternion::operator*= ().

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

返回 QQuaternion object that is the sum of the given quaternions, q1 and q2 ;分别相加各分量。

另请参阅 QQuaternion::operator+= ().

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

返回 QQuaternion 对象的形成是通过减去 q2 from q1 ;分别减去各分量。

另请参阅 QQuaternion::operator-= ().

const QQuaternion operator- (const QQuaternion & quaternion )

这是重载函数。

返回 QQuaternion object that is formed by changing the sign of all three components of the given quaternion .

相当于 QQuaternion(0,0,0,0) - quaternion .

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

返回 QQuaternion object formed by dividing all components of the given quaternion 通过给定 divisor .

另请参阅 QQuaternion::operator/= ().

QDataStream & operator<< ( QDataStream & stream , const QQuaternion & quaternion )

写入给定 quaternion 到给定 stream 并返回流引用。

另请参阅 序列化 Qt 数据类型 .

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

返回 true 若 q1 等于 q2 ; otherwise returns false. This operator uses an exact floating-point comparison.

QDataStream & operator>> ( QDataStream & stream , QQuaternion & quaternion )

读取四元数从给定 stream 进给定 quaternion 并返回流引用。

另请参阅 序列化 Qt 数据类型 .

QDataStream & operator>> ( QDataStream & stream , QEasingCurve & easing )

Reads an easing curve from the given stream 进给定 easing curve and returns a reference to the stream.

另请参阅 序列化 Qt 数据类型 .