Home · All Classes · Modules

QQuaternion Class Reference
[QtGui module]

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

Methods

Static Methods

Special Methods


Detailed Description

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.


Method Documentation

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.

See also 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".

See also lengthSquared() and normalized().

float QQuaternion.lengthSquared (self)

Returns the squared length of the quaternion.

See also length().

QQuaternion QQuaternion.nlerp (QQuaternion q1, QQuaternion q2, float t)

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

If t is less than or equal to 0, then q1 will be returned. If t is greater than or equal to 1, then q2 will be returned.

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

See also 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.

See also 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.

See also 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.

See also setScalar(), x(), y(), and z().

QQuaternion.setScalar (self, float aScalar)

Sets the scalar component of this quaternion to scalar.

See also scalar(), setX(), setY(), and setZ().

QQuaternion.setVector (self, QVector3D aVector)

Sets the vector component of this quaternion to vector.

See also vector() and setScalar().

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

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

See also vector() and setScalar().

QQuaternion.setX (self, float aX)

Sets the x coordinate of this quaternion's vector to the given x coordinate.

See also x(), setY(), setZ(), and setScalar().

QQuaternion.setY (self, float aY)

Sets the y coordinate of this quaternion's vector to the given y coordinate.

See also y(), setX(), setZ(), and setScalar().

QQuaternion.setZ (self, float aZ)

Sets the z coordinate of this quaternion's vector to the given z coordinate.

See also z(), setX(), setY(), and setScalar().

QQuaternion QQuaternion.slerp (QQuaternion q1, QQuaternion q2, float t)

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

If t is less than or equal to 0, then q1 will be returned. If t is greater than or equal to 1, then q2 will be returned.

See also nlerp().

QVector4D QQuaternion.toVector4D (self)

Returns this quaternion as a 4D vector.

QVector3D QQuaternion.vector (self)

Returns the vector component of this quaternion.

See also setVector() and scalar().

float QQuaternion.x (self)

Returns the x coordinate of this quaternion's vector.

See also setX(), y(), z(), and scalar().

float QQuaternion.y (self)

Returns the y coordinate of this quaternion's vector.

See also setY(), x(), z(), and scalar().

float QQuaternion.z (self)

Returns the z coordinate of this quaternion's vector.

See also setZ(), x(), y(), and 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)


PyQt 4.10.1 for MacOSCopyright © Riverbank Computing Ltd and Nokia 2012Qt 4.8.4