QQuaternion Class Reference

[ QtGui module]

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

方法

Static Methods

Special Methods


详细描述

This class can be pickled.

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.__init__ ( self )

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

QQuaternion.__init__ ( self , float  aScalar , float  xpos , float  ypos , float  zpos )

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

QQuaternion.__init__ ( self , float  aScalar , QVector3D   aVector )

Constructs a quaternion vector from the specified vector and scalar .

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

QQuaternion.__init__ ( self , QVector4D   aVector )

Constructs a quaternion from the components of vector .

QQuaternion.__init__ ( self , QQuaternion )

QQuaternion QQuaternion.conjugate ( self )

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

QQuaternion QQuaternion.fromAxisAndAngle ( QVector3D   axis , float  angle )

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

QQuaternion QQuaternion.fromAxisAndAngle (float  x , float  y , float  z , float  angle )

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

bool QQuaternion.isIdentity ( self )

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 ( self )

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

float QQuaternion.length ( self )

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

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

float QQuaternion.lengthSquared ( self )

Returns the squared length of the quaternion.

另请参阅 length ().

QQuaternion QQuaternion.nlerp ( QQuaternion   q1 , QQuaternion   q2 , float  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 将是 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 ().

QQuaternion.normalize ( self )

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 () and normalized ().

QQuaternion QQuaternion.normalized ( self )

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 () and normalize ().

QVector3D QQuaternion.rotatedVector ( self , QVector3D   vector )

Rotates vector 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();
			

float QQuaternion.scalar ( self )

Returns the scalar component of this quaternion.

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

QQuaternion.setScalar ( self , float  aScalar )

Sets the scalar component of this quaternion to scalar .

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

QQuaternion.setVector ( self , QVector3D   aVector )

Sets the vector component of this quaternion to vector .

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

QQuaternion.setVector ( self , float  aX , float  aY , float  aZ )

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

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

QQuaternion.setX ( self , float  aX )

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

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

QQuaternion.setY ( self , float  aY )

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

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

QQuaternion.setZ ( self , float  aZ )

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

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

QQuaternion QQuaternion.slerp ( QQuaternion   q1 , QQuaternion   q2 , float  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 将是 returned. If t is greater than or equal to 1, then q2 将被返回。

另请参阅 nlerp ().

QVector4D QQuaternion.toVector4D ( self )

Returns this quaternion as a 4D vector.

QVector3D QQuaternion.vector ( self )

Returns the vector component of this quaternion.

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

float QQuaternion.x ( self )

Returns the x coordinate of this quaternion's vector.

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

float QQuaternion.y ( self )

Returns the y coordinate of this quaternion's vector.

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

float QQuaternion.z ( self )

Returns the z coordinate of this quaternion's vector.

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

QQuaternion QQuaternion.__add__ ( self , QQuaternion   q2 )

QQuaternion QQuaternion.__div__ ( self , float  divisor )

bool QQuaternion.__eq__ ( self , QQuaternion   q2 )

QQuaternion QQuaternion.__iadd__ ( self , QQuaternion   quaternion )

QQuaternion QQuaternion.__idiv__ ( self , float  divisor )

QQuaternion QQuaternion.__imul__ ( self , float  factor )

QQuaternion QQuaternion.__imul__ ( self , QQuaternion   quaternion )

QQuaternion QQuaternion.__isub__ ( self , QQuaternion   quaternion )

QQuaternion QQuaternion.__mul__ ( self , QQuaternion   q2 )

QQuaternion QQuaternion.__mul__ ( self , QQuaternion   quaternion )

QQuaternion QQuaternion.__mul__ ( self , float  factor )

bool QQuaternion.__ne__ ( self , QQuaternion   q2 )

QQuaternion QQuaternion.__neg__ ( self )

str QQuaternion.__repr__ ( self )

QQuaternion QQuaternion.__sub__ ( self , QQuaternion   q2 )