Safe Haskell | None |
---|---|
Language | Haskell98 |
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
Synopsis
- data HBasis
- type Quaternion k = Vect k HBasis
- i :: Num k => Quaternion k
- j :: Num k => Quaternion k
- k :: 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
- (<.>) :: (Num k, Eq k) => Vect k HBasis -> Vect k HBasis -> k
- (^-) :: (Eq a1, Fractional a2, Num a1) => a2 -> a1 -> a2
- refl :: (Num k, Eq k, Ord a, Show a, HasConjugation k a) => Vect k a -> Vect k a -> Vect k a
- asMatrix :: (Num a, Eq a) => (Vect a HBasis -> Vect a HBasis) -> [Vect a HBasis] -> [[a]]
- 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' :: Num k => Vect k (Dual HBasis)
- i' :: Num k => Vect k (Dual HBasis)
- j' :: Num k => Vect k (Dual HBasis)
- k' :: Num k => Vect k (Dual HBasis)
Documentation
type Quaternion k = Vect k HBasis Source #
i :: Num k => Quaternion k Source #
The quaternions have {1,i,j,k} as basis, where i^2 = j^2 = k^2 = ijk = -1.
j :: Num k => Quaternion k Source #
The quaternions have {1,i,j,k} as basis, where i^2 = j^2 = k^2 = ijk = -1.
k :: Num k => Quaternion k Source #
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 where Source #
conj :: Vect k a -> Vect k a Source #
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
sqnorm :: Vect k a -> k Source #
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
scalarPart :: Num k => Quaternion k -> k Source #
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 k Source #
The vector part of the quaternion w+xi+yj+zk is xi+yj+zk. Also called the pure part.
refl :: (Num k, Eq k, Ord a, Show a, HasConjugation k a) => Vect k a -> Vect k a -> Vect k a Source #
reprSO3' :: Fractional a => a -> a -> a Source #
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 -> a Source #
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.
Orphan instances
(Eq k, Fractional k, Ord a, Show a, HasConjugation k a) => Fractional (Vect k a) Source # | If an algebra has a conjugation operation, then it has multiplicative inverses, via 1/x = conj x / sqnorm x |