The Quaternion class.
attitude can be:
>>> import qmath
>>> qmath.quaternion(1)
(1.0)
>>> qmath.quaternion(1+1j)
(1.0+1.0i)
>>> 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)
>>> qmath.quaternion('1+1i+3j-2k')
(1.0+1.0i+3.0j-2.0k)
>>> qmath.quaternion(0.5 * math.pi, [0,0,1])
(0.968912421711+0.247403959255k)
>>> import math
>>> qmath.quaternion([0.0,math.pi / 6,math.pi / 3])
(0.836516303738+0.482962913145i+0.224143868042j-0.129409522551k)
>>> 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.
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.