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

Class Quaternion

source code

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 = Object(wrappedObject) #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 [hide private]
New quaternion object.
__init__(list, angle=None)
Create a new quaternion object from initialized values.
source code
 
identity()
Set the quaternion to the identity quaternion.
source code
 
copy()
make a copy of the quaternion.
source code
 
negate()
Set the quaternion to its negative.
source code
 
conjugate()
Set the quaternion to its conjugate.
source code
 
inverse()
Set the quaternion to its inverse
source code
 
normalize()
Normalize the quaternion.
source code
Euler object
toEuler()
Return Euler representation of the quaternion.
source code
Matrix object
toMatrix()
Return a matrix representation of the quaternion.
source code
Instance Variables [hide private]
  angle
A scalar representing the amount of rotation in degrees.
  axis
Vector representing the axis of rotation.
  magnitude
The magnitude of the quaternion.
  w
The w value.
  wrapped
Wether or not this object wraps data directly
  x
The x value.
  y
The y value.
  z
The z value.
Method Details [hide private]

__init__(list, angle=None)
(Constructor)

source code 

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

source code 

Set the quaternion to the identity quaternion.

Returns:
an instance of itself

copy()

source code 

make a copy of the quaternion.

Returns:
a copy of itself

negate()

source code 

Set the quaternion to its negative.

Returns:
an instance of itself

conjugate()

source code 

Set the quaternion to its conjugate.

Returns:
an instance of itself

inverse()

source code 

Set the quaternion to its inverse

Returns:
an instance of itself

normalize()

source code 

Normalize the quaternion.

Returns:
an instance of itself

toEuler()

source code 

Return Euler representation of the quaternion.

Returns: Euler object
Euler representation of the quaternion.

toMatrix()

source code 

Return a matrix representation of the quaternion.

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