Classes

quaternion()

class quaternion(attitude[, matrix = np.identity(3)])

The Quaternion class.

attitude can be:

  • a number (of any type, complex are included);
>>> import qmath
>>> qmath.quaternion(1)
(1.0)
>>> qmath.quaternion(1+1j)
(1.0+1.0i)
  • a list or a numpy array of the components with respect to 1, i, j and k;
>>> qmath.quaternion([1,2,3,4])
(1.0+2.0i+3.0j+4.0k)
>>> qmath.quaternion(np.array([1,2,3,4]))
(1.0+2.0i+3.0j+4.0k)
  • a string of the form ‘a+bi+cj+dk’;
>>> qmath.quaternion('1+1i+3j-2k')
(1.0+1.0i+3.0j-2.0k)
  • a rotation about an axis using pairs (rotation angle, axis of rotation);
>>> qmath.quaternion(0.5 * math.pi, [0,0,1])
(0.968912421711+0.247403959255k)
  • a list whose components are Euler angles;
>>> import math
>>> qmath.quaternion([0.0,math.pi / 6,math.pi / 3])
(0.836516303738+0.482962913145i+0.224143868042j-0.129409522551k)
  • a 3X3 rotation matrix. The matrix must be given as a numpy array.
>>> import numpy as np
>>> qmath.quaternion(np.array([[0  ,-0.8 ,-0.6],
...                            [0.8,-0.36, 0.48],
...                            [0.6,0.48 ,-0.64]]))
(0.707106781187i+0.565685424949j+0.424264068712k)

matrix is a 3X3 symmetric matrix defining the product in the quaternion algebra. The identity matrix is by default: this choiche yields to classical Hamilton quaternions. Different choiches of this matrix lead to generalized quaternion algebras. For example, if

matrix = np.array([[-1,0,0],[0,1,0],[0,0,-1]])

one gets the algebra of square matrices of order two.

hurwitz()

class hurwitz(attitude[, matrix = np.identity(3)])

The class of Hurwitz quaternions, i.e. quaternions whose components are integers.

attitude can be the same as for quaternion class, if the components as a quaternion are integers.

Table Of Contents

Previous topic

Installation

Next topic

Methods

This Page