# Module Scientific.Geometry.Quaternion

## Functions

- isQuaternion(x)

  Returns 1 if x is a quaternion.

## Class Quaternion: Quaternion (hypercomplex number)

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

Constructor:

- Quaternion(q0, q1, q2, q3) (from four real components)

- Quaternion(q) (from a sequence containing the four components)

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.

Methods:

- norm()

  Returns the norm.

- normalized()

  Returns the quaternion scaled to norm 1.

- inverse()

  Returns the inverse.

- asMatrix()

  Returns a 4x4 matrix representation.

- asRotation()

  Returns the corresponding rotation matrix (the quaternion must be normalized).