Module Mathutils :: Class Quaternion
[frames] | no frames]

Class Quaternion

The Quaternion object

This object gives access to Quaternions in Blender.


Notes:

Attention: Quaternion data can be wrapped or non-wrapped. When a object is wrapped it means that the object will give you direct access to the data inside of blender. Modification of this object will directly change the data inside of blender. To copy a wrapped object you need to use the object's constructor. If you copy and object by assignment you will not get a second copy but a second reference to the same data. Only certain functions will return wrapped data. This will be indicated in the method description. Example:

   wrappedObject = Object.getAttribute() #this is wrapped data
   print wrappedObject.wrapped #prints 'True'
   copyOfObject = wrappedObject.copy() #creates a copy of the object
   secondPointer = wrappedObject #creates a second pointer to the same data
   print wrappedObject.attribute #prints '5'
   secondPointer.attribute = 10
   print wrappedObject.attribute #prints '10'
   print copyOfObject.attribute #prints '5'

Instance Methods
New quaternion object.
__init__(list, angle=None)
Create a new quaternion object from initialized values.
 
identity()
Set the quaternion to the identity quaternion.
 
copy()
make a copy of the quaternion.
 
negate()
Set the quaternion to its negative.
 
conjugate()
Set the quaternion to its conjugate.
 
inverse()
Set the quaternion to its inverse
 
normalize()
Normalize the quaternion.
Euler object
toEuler(eul_compat)
Return Euler representation of the quaternion.
Matrix object
toMatrix()
Return a matrix representation of the quaternion.
Vector
cross(other)
Return the cross product of this quaternion and another.
float
dot(other)
Return the dot product of this quaternion and another.
Instance Variables
  angle
A scalar representing the amount of rotation in degrees.
  axis
Vector representing the axis of rotation.
  magnitude
The magnitude of the quaternion.
  wrapped
Wether or not this object wraps data directly
    Axises
  w
The w value.
  x
The x value.
  y
The y value.
  z
The z value.
Method Details

__init__(list, angle=None)
(Constructor)

 

Create a new quaternion object from initialized values.

Example:

 quat = Quaternion(1,2,3,4)
 quat = Quaternion(axis, angle)

quat = Quaternion() quat = Quaternion(180, list)

Parameters:
  • list (PyList of int/float) - A 3d or 4d list to initialize quaternion. 4d if intializing [w,x,y,z], 3d if used as an axis of rotation.
  • angle (float (optional)) - An arbitrary rotation amount around 'list'. List is used as an axis of rotation in this case.
Returns: New quaternion object.
It depends wheter a parameter was passed:
  • (list/angle): Quaternion object initialized with the given values;
  • (): An identity 4 dimensional quaternion.

identity()

 

Set the quaternion to the identity quaternion.

Returns:
an instance of itself

copy()

 

make a copy of the quaternion.

Returns:
a copy of itself

negate()

 

Set the quaternion to its negative.

Returns:
an instance of itself

conjugate()

 

Set the quaternion to its conjugate.

Returns:
an instance of itself

inverse()

 

Set the quaternion to its inverse

Returns:
an instance of itself

normalize()

 

Normalize the quaternion.

Returns:
an instance of itself

toEuler(eul_compat)

 

Return Euler representation of the quaternion.

Parameters:
  • eul_compat (Euler) - Optional euler argument the new euler will be made compatible with (no axis flipping between them). Useful for converting a series of matrices to animation curves.
Returns: Euler object
Euler representation of the quaternion.

toMatrix()

 

Return a matrix representation of the quaternion.

Returns: Matrix object
A 3x3 rotation matrix representation of the quaternion.

cross(other)

 

Return the cross product of this quaternion and another.

Parameters:
  • other (Quaterion object) - The other quaternion to perform the cross product with.
Returns: Vector
The cross product.

dot(other)

 

Return the dot product of this quaternion and another.

Parameters:
  • other (Quaterion object) - The other quaternion to perform the dot product with.
Returns: float
The dot product.