Table Of Contents

Previous topic

QMatrix4x4

Next topic

QVector4D

QQuaternion

Note

This class was introduced in Qt 4.6

Synopsis

Functions

Static functions

Detailed Description

The PySide.QtGui.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.

class PySide.QtGui.QQuaternion
class PySide.QtGui.QQuaternion(QQuaternion)
class PySide.QtGui.QQuaternion(vector)
class PySide.QtGui.QQuaternion(scalar, vector)
class PySide.QtGui.QQuaternion(scalar, xpos, ypos, zpos)
Parameters:

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

Constructs a quaternion from the components of vector .

Constructs a quaternion vector from the specified vector and scalar .

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

PySide.QtGui.QQuaternion.__reduce__()
Return type:PyObject
PySide.QtGui.QQuaternion.__repr__()
Return type:PyObject
PySide.QtGui.QQuaternion.conjugate()
Return type:PySide.QtGui.QQuaternion

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

static PySide.QtGui.QQuaternion.fromAxisAndAngle(x, y, z, angle)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • zPySide.QtCore.qreal
  • anglePySide.QtCore.qreal
Return type:

PySide.QtGui.QQuaternion

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

static PySide.QtGui.QQuaternion.fromAxisAndAngle(axis, angle)
Parameters:
Return type:

PySide.QtGui.QQuaternion

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

PySide.QtGui.QQuaternion.isIdentity()
Return type:PySide.QtCore.bool

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.

PySide.QtGui.QQuaternion.isNull()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QQuaternion.length()
Return type:PySide.QtCore.qreal

Returns the length of the quaternion. This is also called the “norm”.

PySide.QtGui.QQuaternion.lengthSquared()
Return type:PySide.QtCore.qreal

Returns the squared length of the quaternion.

static PySide.QtGui.QQuaternion.nlerp(q1, q2, t)
Parameters:
Return type:

PySide.QtGui.QQuaternion

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 PySide.QtGui.QQuaternion.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 PySide.QtGui.QQuaternion.nlerp() function is typically faster than PySide.QtGui.QQuaternion.slerp() and will give approximate results to spherical interpolation that are good enough for some applications.

PySide.QtGui.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.

PySide.QtGui.QQuaternion.normalized()
Return type:PySide.QtGui.QQuaternion

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.

PySide.QtGui.QQuaternion.__ne__(q2)
Parameters:q2PySide.QtGui.QQuaternion
Return type:PySide.QtCore.bool
PySide.QtGui.QQuaternion.__mul__(factor)
Parameters:factorPySide.QtCore.qreal
Return type:PySide.QtGui.QQuaternion
PySide.QtGui.QQuaternion.__mul__(factor)
Parameters:factorPySide.QtCore.qreal
Return type:PySide.QtGui.QQuaternion
PySide.QtGui.QQuaternion.__mul__(q2)
Parameters:q2PySide.QtGui.QQuaternion
Return type:PySide.QtGui.QQuaternion
PySide.QtGui.QQuaternion.__imul__(factor)
Parameters:factorPySide.QtCore.qreal
Return type:PySide.QtGui.QQuaternion

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

See also

PySide.QtGui.QQuaternion.operator/=()

PySide.QtGui.QQuaternion.__imul__(quaternion)
Parameters:quaternionPySide.QtGui.QQuaternion
Return type:PySide.QtGui.QQuaternion

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

PySide.QtGui.QQuaternion.__add__(q2)
Parameters:q2PySide.QtGui.QQuaternion
Return type:PySide.QtGui.QQuaternion
PySide.QtGui.QQuaternion.__iadd__(quaternion)
Parameters:quaternionPySide.QtGui.QQuaternion
Return type:PySide.QtGui.QQuaternion

Adds the given quaternion to this quaternion and returns a reference to this quaternion.

See also

PySide.QtGui.QQuaternion.operator-=()

PySide.QtGui.QQuaternion.__sub__()
Return type:PySide.QtGui.QQuaternion
PySide.QtGui.QQuaternion.__sub__(q2)
Parameters:q2PySide.QtGui.QQuaternion
Return type:PySide.QtGui.QQuaternion
PySide.QtGui.QQuaternion.__isub__(quaternion)
Parameters:quaternionPySide.QtGui.QQuaternion
Return type:PySide.QtGui.QQuaternion

Subtracts the given quaternion from this quaternion and returns a reference to this quaternion.

See also

PySide.QtGui.QQuaternion.operator+=()

PySide.QtGui.QQuaternion.__div__(divisor)
Parameters:divisorPySide.QtCore.qreal
Return type:PySide.QtGui.QQuaternion
PySide.QtGui.QQuaternion.__idiv__(divisor)
Parameters:divisorPySide.QtCore.qreal
Return type:PySide.QtGui.QQuaternion

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

See also

PySide.QtGui.QQuaternion.operator*=()

PySide.QtGui.QQuaternion.__eq__(q2)
Parameters:q2PySide.QtGui.QQuaternion
Return type:PySide.QtCore.bool
PySide.QtGui.QQuaternion.rotatedVector(vector)
Parameters:vectorPySide.QtGui.QVector3D
Return type:PySide.QtGui.QVector3D

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();
PySide.QtGui.QQuaternion.scalar()
Return type:PySide.QtCore.qreal

Returns the scalar component of this quaternion.

PySide.QtGui.QQuaternion.setScalar(scalar)
Parameters:scalarPySide.QtCore.qreal

Sets the scalar component of this quaternion to scalar .

PySide.QtGui.QQuaternion.setVector(vector)
Parameters:vectorPySide.QtGui.QVector3D

Sets the vector component of this quaternion to vector .

PySide.QtGui.QQuaternion.setVector(x, y, z)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • zPySide.QtCore.qreal

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

PySide.QtGui.QQuaternion.setX(x)
Parameters:xPySide.QtCore.qreal

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

PySide.QtGui.QQuaternion.setY(y)
Parameters:yPySide.QtCore.qreal

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

PySide.QtGui.QQuaternion.setZ(z)
Parameters:zPySide.QtCore.qreal

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

static PySide.QtGui.QQuaternion.slerp(q1, q2, t)
Parameters:
Return type:

PySide.QtGui.QQuaternion

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.

PySide.QtGui.QQuaternion.toVector4D()
Return type:PySide.QtGui.QVector4D

Returns this quaternion as a 4D vector.

PySide.QtGui.QQuaternion.vector()
Return type:PySide.QtGui.QVector3D

Returns the vector component of this quaternion.

PySide.QtGui.QQuaternion.x()
Return type:PySide.QtCore.qreal

Returns the x coordinate of this quaternion’s vector.

PySide.QtGui.QQuaternion.y()
Return type:PySide.QtCore.qreal

Returns the y coordinate of this quaternion’s vector.

PySide.QtGui.QQuaternion.z()
Return type:PySide.QtCore.qreal

Returns the z coordinate of this quaternion’s vector.