Package Scientific :: Package Geometry :: Module Quaternion :: Class Quaternion
[frames] | no frames]

Class Quaternion

Quaternion (hypercomplex number)

This implementation of quaternions is not complete; only the features needed for representing rotation matrices by quaternions are implemented.

Quaternions support addition, subtraction, and multiplication, as well as multiplication and division by scalars. Division by quaternions is not provided, because quaternion multiplication is not associative. Use multiplication by the inverse instead.

The four components can be extracted by indexing.

Instance Methods
 
__add__(self, other)
 
__div__(self, other)
 
__getitem__(self, item)
 
__init__(self, *data)
There are two calling patterns:
 
__mul__(self, other)
 
__rdiv__(self, other)
 
__repr__(self)
 
__rmul__(self, other)
 
__sub__(self, other)
Numeric.array
asMatrix(self)
Returns: a 4x4 matrix representation
Scientific.Geometry.Transformation.Rotation
asRotation(self)
Returns: the corresponding rotation matrix
 
dot(self, other)
Quaternion
inverse(self)
Returns: the inverse
float
norm(self)
Returns: the norm
Quaternion
normalized(self)
Returns: the quaternion scaled such that its norm is 1
Class Variables
  is_quaternion = 1
Method Details

__init__(self, *data)
(Constructor)

 

There are two calling patterns:

  • Quaternion(q0, q1, q2, q3) (from four real components)
  • Quaternion(q) (from a sequence containing the four components)

asMatrix(self)

 
Returns: Numeric.array
a 4x4 matrix representation

asRotation(self)

 
Returns: Scientific.Geometry.Transformation.Rotation
the corresponding rotation matrix
Raises:
  • ValueError - if the quaternion is not normalized

inverse(self)

 
Returns: Quaternion
the inverse

norm(self)

 
Returns: float
the norm

normalized(self)

 
Returns: Quaternion
the quaternion scaled such that its norm is 1