[frames | no frames]

# The Quaternion object

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'
```

Notes:

• Comparison operators can be done:
• ==, != test numeric values within epsilon
• Math can be performed on Quaternion classes
• quat + quat
• quat - quat
• quat * float/int
• quat * vec
• quat * quat
• You can access a quaternion object like a sequence
• x = quat

Method Summary
New quaternion object. ```__init__(list, angle)```
Create a new quaternion object from initialized values.
`conjugate()`
Set the quaternion to its conjugate.
`copy()`
make a copy of the quaternion.
`identity()`
Set the quaternion to the identity quaternion.
`inverse()`
Set the quaternion to its inverse
`negate()`
Set the quaternion to its negative.
`normalize()`
Normalize the quaternion.
Euler object `toEuler()`
Return Euler representation of the quaternion.
Matrix object `toMatrix()`
Return a matrix representation of the quaternion.

Instance Variable Summary
`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

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

(type=New quaternion object.)

### conjugate()

Set the quaternion to its conjugate.
Returns:
an instance of itself

### copy()

make a copy of the quaternion.
Returns:
a copy of itself

### identity()

Set the quaternion to the identity quaternion.
Returns:
an instance of itself

### inverse()

Set the quaternion to its inverse
Returns:
an instance of itself

### negate()

Set the quaternion to its negative.
Returns:
an instance of itself

### normalize()

Normalize the quaternion.
Returns:
an instance of itself

### toEuler()

Return Euler representation of the quaternion.
Returns:
Euler representation of the quaternion.
(type=Euler object)

### toMatrix()

Return a matrix representation of the quaternion.
Returns:
A rotation matrix representation of the quaternion.
(type=Matrix object)

Instance Variable Details

### angle

A scalar representing the amount of rotation in degrees.

### axis

Vector representing the axis of rotation.

### magnitude

The magnitude of the quaternion.

The w value.

### wrapped

Wether or not this object wraps data directly

The x value.

The y value.

### z

The z value.

 Generated by Epydoc 2.1 on Sun Feb 11 13:30:19 2007 http://epydoc.sf.net