Safe Haskell | Safe-Infered |
---|

A module defining the algebra of quaternions over an arbitrary field.

The quaternions are the algebra defined by the basis {1,i,j,k}, where i^2 = j^2 = k^2 = ijk = -1

- data HBasis
- type Quaternion k = Vect k HBasis
- i, k, j :: Num k => Quaternion k
- class Algebra k a => HasConjugation k a where
- scalarPart :: Num k => Quaternion k -> k
- vectorPart :: (Eq k, Num k) => Quaternion k -> Quaternion k
- (<.>) :: (Eq k, Num k) => Vect k HBasis -> Quaternion k -> k
- (^-) :: (Eq a, Fractional a1, Num a) => a1 -> a -> a1
- refl :: (Eq k, Num k, Ord a, Show a, HasConjugation k a) => Vect k a -> Vect k a -> Vect k a
- asMatrix :: (Eq t, Num t) => (Vect t HBasis -> Quaternion t) -> [Vect t HBasis] -> [[t]]
- reprSO3' :: Fractional a => a -> a -> a
- reprSO3 :: (Eq k, Fractional k) => Quaternion k -> [[k]]
- reprSO4' :: Fractional a => (a, a) -> a -> a
- reprSO4 :: (Eq k, Fractional k) => (Quaternion k, Quaternion k) -> [[k]]
- reprSO4d :: (Eq k, Fractional k) => Vect k (DSum HBasis HBasis) -> [[k]]
- one', k', j', i' :: Num k => Vect k (Dual HBasis)

# Documentation

type Quaternion k = Vect k HBasisSource

i, k, j :: Num k => Quaternion kSource

The quaternions have {1,i,j,k} as basis, where i^2 = j^2 = k^2 = ijk = -1.

class Algebra k a => HasConjugation k a whereSource

conj :: Vect k a -> Vect k aSource

A conjugation operation is required to satisfy the following laws:

- conj (x+y) = conj x + conj y
- conj (x*y) = conj y * conj x (note the order-reversal)
- conj (conj x) = x
- conj x = x if and only if x in k

The squared norm is defined as sqnorm x = x * conj x. It satisfies:

- sqnorm (x*y) = sqnorm x * sqnorm y
- sqnorm (unit k) = k^2, for k a scalar

(Eq k, Num k) => HasConjugation k HBasis | |

(Eq k, Num k) => HasConjugation k OBasis |

scalarPart :: Num k => Quaternion k -> kSource

The scalar part of the quaternion w+xi+yj+zk is w. Also called the real part.

vectorPart :: (Eq k, Num k) => Quaternion k -> Quaternion kSource

The vector part of the quaternion w+xi+yj+zk is xi+yj+zk. Also called the pure part.

(^-) :: (Eq a, Fractional a1, Num a) => a1 -> a -> a1Source

reprSO3' :: Fractional a => a -> a -> aSource

reprSO3 :: (Eq k, Fractional k) => Quaternion k -> [[k]]Source

Given a non-zero quaternion q in H, the map x -> q^-1 * x * q defines an action on the 3-dimensional vector space of pure quaternions X (ie linear combinations of i,j,k). It turns out that this action is a rotation of X, and this is a surjective group homomorphism from H* onto SO3. If we restrict q to the group of unit quaternions (those of norm 1), then this homomorphism is 2-to-1 (since q and -q give the same rotation). This shows that the multiplicative group of unit quaternions is isomorphic to Spin3, the double cover of SO3.

`reprSO3 q`

returns the 3*3 matrix representing this map.

reprSO4' :: Fractional a => (a, a) -> a -> aSource

reprSO4 :: (Eq k, Fractional k) => (Quaternion k, Quaternion k) -> [[k]]Source

Given a pair of unit quaternions (l,r), the map x -> l^-1 * x * r defines an action on the 4-dimensional space of quaternions. It turns out that this action is a rotation, and this is a surjective group homomorphism onto SO4. The homomorphism is 2-to-1 (since (l,r) and (-l,-r) give the same map). This shows that the multiplicative group of pairs of unit quaternions (with pointwise multiplication) is isomorphic to Spin4, the double cover of SO4.

`reprSO4 (l,r)`

returns the 4*4 matrix representing this map.