OpenMaya.MQuaternion Class Reference

Class Description

Quaternion math.

Constructors

SignatureParametersDescription
MQuaternion()  

Default constructor. Returns a new MQuaternion object, initialized to the multiplicative identity.

MQuaternion(src) src - MQuaternion

Copy constructor. Returns a new MQuaternion object with the same value as src.

MQuaternion(x, y, z, w) x - float
y - float
z - float
w - float

Returns a new MQuaternion object with its imaginary components set to x, y and z and its real component set to w.

MQuaternion(seq) seq - sequence of 4 floats

Returns a new MQuaternion object with its x, y, z, and w components set to the elements of seq.

MQuaternion(a, b, factor=1.0) a - MVector
b - MVector
factor - float

Returns a new MQuaternion which will rotate vector a into vector b, about their mutually perpendicular axis. If factor is less than 1 then it will rotate only part of the way into b. If factor is greater than 1 then it will overshoot b.

MQuaternion(angle, axis) angle - float
axis - MVector

Returns a new MQuaternion representing a rotation of angle radians about axis.

Sequence Support

An MQuaternion is treated as a sequence of four float values: [x, y, z, w].

len() returns 4.

Indexing and element assignment are supported.

Deletion, concatenation, repetition and slicing are not supported.

Number Support

OperationResult
MQuaternion = MQuaternion + MQuaternion

Component-by-component addition.

MQuaternion = MQuaternion - MQuaternion

Component-by-component subtraction.

MQuaternion = -MQuaternion

Component-by-component negation.

MQuaternion = MQuaternion * MQuaternion

Multiplication by another quaternion.

MQuaternion *= MQuaternion

In-place multiplication by another quaternion. Returns a reference to the left operand.

MQuaternion = float * MQuaternion

Scaling of each component by the float.

Comparison Support

==

Exact equality comparison. Returns True if each component of the left operand is exactly equal to the corresponding component of the right operand.

!= Exact inequality comparison. Returns True if any component of the left operand is not exactly equal to the corresponding component of the right operand.

All other comparison operators will raise a TypeError exception.

 


+ Inheritance diagram for OpenMaya.MQuaternion:

Public Member Functions

__add__ ()
 
__delitem__ ()
 
__eq__ ()
 
__ge__ ()
 
__getitem__ ()
 
__gt__ ()
 
__imul__ ()
 
__init__ ()
 
__le__ ()
 
__len__ ()
 
__lt__ ()
 
__mul__ ()
 
__ne__ ()
 
__neg__ ()
 
__radd__ ()
 
__repr__ ()
 
__rmul__ ()
 
__rsub__ ()
 
__setitem__ ()
 
__str__ ()
 
__sub__ ()
 
asAxisAngle ()
 
asEulerRotation ()
 
asMatrix ()
 
conjugate ()
 
conjugateIt ()
 
exp ()
 
inverse ()
 
invertIt ()
 
isEquivalent ()
 
log ()
 
negateIt ()
 
normal ()
 
normalizeIt ()
 
setToXAxis ()
 
setToYAxis ()
 
setToZAxis ()
 
setValue ()
 

Static Public Member Functions

slerp ()
 
squad ()
 
squadPt ()
 

Static Public Attributes

tuple kIdentity = maya.api.OpenMaya.MQuaternion(0, 0, 0, 1)
 
int kTolerance = 1
 

Properties

 w
 
 x
 
 y
 
 z
 

Constructor & Destructor Documentation

OpenMaya.MQuaternion.__init__ ( )
x.__init__(...) initializes x; see help(type(x)) for signature

Member Function Documentation

OpenMaya.MQuaternion.__add__ ( )
x.__add__(y) <==> x+y
OpenMaya.MQuaternion.__delitem__ ( )
x.__delitem__(y) <==> del x[y]
OpenMaya.MQuaternion.__eq__ ( )
x.__eq__(y) <==> x==y
OpenMaya.MQuaternion.__ge__ ( )
x.__ge__(y) <==> x>=y
OpenMaya.MQuaternion.__getitem__ ( )
x.__getitem__(y) <==> x[y]
OpenMaya.MQuaternion.__gt__ ( )
x.__gt__(y) <==> x>y
OpenMaya.MQuaternion.__imul__ ( )
x.__imul__(y) <==> x*=y
OpenMaya.MQuaternion.__le__ ( )
x.__le__(y) <==> x<=y
OpenMaya.MQuaternion.__len__ ( )
x.__len__() <==> len(x)
OpenMaya.MQuaternion.__lt__ ( )
x.__lt__(y) <==> x<y
OpenMaya.MQuaternion.__mul__ ( )
x.__mul__(y) <==> x*y
OpenMaya.MQuaternion.__ne__ ( )
x.__ne__(y) <==> x!=y
OpenMaya.MQuaternion.__neg__ ( )
x.__neg__() <==> -x
OpenMaya.MQuaternion.__radd__ ( )
x.__radd__(y) <==> y+x
OpenMaya.MQuaternion.__repr__ ( )
x.__repr__() <==> repr(x)
OpenMaya.MQuaternion.__rmul__ ( )
x.__rmul__(y) <==> y*x
OpenMaya.MQuaternion.__rsub__ ( )
x.__rsub__(y) <==> y-x
OpenMaya.MQuaternion.__setitem__ ( )
x.__setitem__(i, y) <==> x[i]=y
OpenMaya.MQuaternion.__str__ ( )
x.__str__() <==> str(x)
OpenMaya.MQuaternion.__sub__ ( )
x.__sub__(y) <==> x-y
OpenMaya.MQuaternion.asAxisAngle ( )
Returns the rotation as a tuple containing an axis vector and an angle in radians about that axis.
Signature: asAxisAngle()
Parameters:  
Returns: (MVector, float)
Description: Returns a tuple containing an axis and angle in radians which is equivalent to the rotation represented by the quaternion.
OpenMaya.MQuaternion.asEulerRotation ( )
Returns the rotation as an equivalent MEulerRotation.
Signature: asEulerRotation()
Parameters:  
Returns: MEulerRotation
Description: Returns the quaternion as an equivalent euler rotation.
OpenMaya.MQuaternion.asMatrix ( )
Returns the rotation as an equivalent rotation matrix.
Signature: asMatrix()
Parameters:  
Returns: MMatrix
Description: Returns the quaternion as an equivalent rotation matrix.
OpenMaya.MQuaternion.conjugate ( )
Returns the conjugate of this quaternion (i.e. x, y and z components negated).
Signature: conjugate()
Parameters:  
Returns: MQuaternion
Description: Returns a new quaternion containing the conjugate of this one (i.e. x, y and z components negated).
OpenMaya.MQuaternion.conjugateIt ( )
In-place conjugation (i.e. negates the x, y and z components).
Signature: conjugateIt()
Parameters:  
Returns: Reference to self.
Description: In-place conjugation (i.e. negates the x, y and z components).
OpenMaya.MQuaternion.exp ( )
Returns a new quaternion containing the exponent of this one.
Signature: exp()
Parameters:  
Returns: MQuaternion
Description: Returns a new quaternion containing the exponent of this one.
OpenMaya.MQuaternion.inverse ( )
Returns a new quaternion containing the inverse of this one.
Signature: inverse()
Parameters:  
Returns: MQuaternion
Description: Returns a new quaternion containing the inverse of this one.
OpenMaya.MQuaternion.invertIt ( )
In-place inversion.
Signature: invertIt()
Parameters:  
Returns: Reference to self.
Description: In-place inversion.
OpenMaya.MQuaternion.isEquivalent ( )
Returns True if the distance between the two quaternions (in quaternion space) is less than or equal to the given tolerance.
Signature: isEquivalent(other, tolerance=kTolerance)
Parameters: other - MQuaternion
tolerance - float
Returns: bool
Description: Returns True if the distance between the two quaternions (in quaternion space) is less than or equal to tolerance.
OpenMaya.MQuaternion.log ( )
Returns a new quaternion containing the natural log of this one.
Signature: log()
Parameters:  
Returns: MQuaternion
Description: Returns a new quaternion containing the natural log of this one.
OpenMaya.MQuaternion.negateIt ( )
In-place negation of the x, y, z and w components.
Signature: negateIt()
Parameters:  
Returns: Reference to self.
Description: In-place negation of the x, y, z and w components.
OpenMaya.MQuaternion.normal ( )
Returns a new quaternion containing the normalized version of this one (i.e. scaled to unit length).
Signature: normal()
Parameters:  
Returns: MQuaternion
Description: Returns a new quaternion containing the normalized version of this one (i.e. scaled to unit length).
OpenMaya.MQuaternion.normalizeIt ( )
In-place normalization (i.e. scales the quaternion to unit length).
Signature: normalizeIt()
Parameters:  
Returns: Reference to self.
Description: In-place normalization (i.e. scales the quaternion to unit length).
OpenMaya.MQuaternion.setToXAxis ( )
Set this quaternion to be equivalent to a rotation of a given angle, in radians, about the X-axis.
Signature: setToXAxis(angle)
Parameters: angle - float
Returns: Reference to self.
Description: Set the value of this quaternion to be equivalent to a rotation of angle radians about the X-axis.
OpenMaya.MQuaternion.setToYAxis ( )
Set this quaternion to be equivalent to a rotation of a given angle, in radians, about the Y-axis.
Signature: setToYAxis(angle)
Parameters: angle - float
Returns: Reference to self.
Description: Set the value of this quaternion to be equivalent to a rotation of angle radians about the Y-axis.
OpenMaya.MQuaternion.setToZAxis ( )
Set this quaternion to be equivalent to a rotation of a given angle, in radians, about the Z-axis.
Signature: setToZAxis(angle)
Parameters: angle - float
Returns: Reference to self.
Description: Set the value of this quaternion to be equivalent to a rotation of angle radians about the Z-axis.
OpenMaya.MQuaternion.setValue ( )
Set the value of this quaternion to that of the specified MQuaternion, MEulerRotation, MMatrix or MVector and angle.
Signature: setValue(quat)
Parameters: quat - MQuaternion
Returns: Reference to self.
Description: Set the value of this quaternion to be the same as quat.
Signature: setValue(rot)
Parameters: rot - MEulerRotation
Returns: Reference to self.
Description: Set the value of this quaternion to be equivalent to the rotation rot.
Signature: setValue(mat)
Parameters: mat - MMatrix
Returns: Reference to self.
Description: Set the value of this quaternion to be equivalent to the rotation derived from decomposing mat.
Signature: setValue(axis, angle)
Parameters: axis - MVector
angle - float
Returns: Reference to self.
Description: Set the value of this quaternion to be equivalent to a rotation of angle radians about axis.
OpenMaya.MQuaternion.slerp ( )
static
Returns the quaternion at a given interpolation value along the shortest path between two quaternions.
Name: slerp(p, q, t, spin=0)
Parameters: p - MQuaternion
q - MQuaternion
t - float
spin - int
Returns: MQuaternion
Description: Spherical interpolation of unit quaternions. Returns a quaternion along the shortest path (in quaternion space) between p and q, at interpolation value t. Thus a value of 0.0 will return p while a value of 1.0 will return q. spins gives the number of complete rotations about the axis which must occur when going from p to q.
OpenMaya.MQuaternion.squad ( )
static
Returns the quaternion at a given interpolation value along a cubic curve segment in quaternion space.
Name: squad(p, a, b, q, t, spin=0)
Parameters: p - MQuaternion
a - MQuaternion
b - MQuaternion
q - MQuaternion
t - float
spin - int
Returns: MQuaternion
Description: Interpolation along a cubic curve segment in quaternion space. Returns a quaternion along the cubic curve segment which interpolates p and q, at interpolation value t. Thus a value of 0.0 will return p while a value of 1.0 will return q. The curve is C1 continuous with a and b as intermediate points. spins gives the number of complete rotations about the axis which must occur when going from p to q.
OpenMaya.MQuaternion.squadPt ( )
static
Returns a new quaternion representing an intermediate point which when used with squad() will produce a C1 continuous spline.
Name: squadPt(q0, q1, q2)
Parameters: q0 - MQuaternion
q1 - MQuaternion
q2 - MQuaternion
Returns: MQuaternion
Description: Returns a new quaternion representing an intermediate point (in quaternion space) which when used with squad() will produce a C1 continuous spline.

Member Data Documentation

OpenMaya.MQuaternion.kIdentity = maya.api.OpenMaya.MQuaternion(0, 0, 0, 1)
static
Name: kIdentity
Type: MQuaternion
Description: Multiplicative identity.
OpenMaya.MQuaternion.kTolerance = 1
static
Name: kTolerance
Type: float
Description: Default tolerance for non-exact equality tests.

Property Documentation

OpenMaya.MQuaternion.w
static
 Real component
Name: w
Type: float
Access: RW
Description: Real component.
OpenMaya.MQuaternion.x
static
 Imaginary X component
Name: x
Type: float
Access: RW
Description: Imaginary X component.
OpenMaya.MQuaternion.y
static
 Imaginary Y component
Name: y
Type: float
Access: RW
Description: Imaginary Y component.
OpenMaya.MQuaternion.z
static
 Imaginary Z component
Name: z
Type: float
Access: RW
Description: Imaginary Z component.