Maintainer | numericprelude@henning-thielemann.de |
---|---|
Stability | provisional |
Portability | portable (?) |
Safe Haskell | None |
Language | Haskell98 |
Quaternions
- data T a
- fromReal :: C a => a -> T a
- (+::) :: a -> (a, a, a) -> T a
- toRotationMatrix :: C a => T a -> Array (Int, Int) a
- fromRotationMatrix :: C a => Array (Int, Int) a -> T a
- fromRotationMatrixDenorm :: C a => Array (Int, Int) a -> T a
- toComplexMatrix :: C a => T a -> Array (Int, Int) (T a)
- fromComplexMatrix :: C a => Array (Int, Int) (T a) -> T a
- scalarProduct :: C a => (a, a, a) -> (a, a, a) -> a
- crossProduct :: C a => (a, a, a) -> (a, a, a) -> (a, a, a)
- conjugate :: C a => T a -> T a
- scale :: C a => a -> T a -> T a
- norm :: C a => T a -> a
- normSqr :: C a => T a -> a
- normalize :: C a => T a -> T a
- similarity :: C a => T a -> T a -> T a
- slerp :: C a => a -> (a, a, a) -> (a, a, a) -> (a, a, a)
Cartesian form
Quaternions could be defined based on Complex numbers. However quaternions are often considered as real part and three imaginary parts.
C T Source # | |
C a b => C a (T b) Source # | The '(*>)' method can't replace |
C a b => C a (T b) Source # | |
(C a, Sqr a b) => C a (T b) Source # | |
Sqr a b => Sqr a (T b) Source # | |
Eq a => Eq (T a) Source # | |
Read a => Read (T a) Source # | |
Show a => Show (T a) Source # | |
C a => C (T a) Source # | |
C a => C (T a) Source # | |
C a => C (T a) Source # | |
C a => C (T a) Source # | |
Conversions
toRotationMatrix :: C a => T a -> Array (Int, Int) a Source #
Let c
be a unit quaternion, then it holds
similarity c (0+::x) == toRotationMatrix c * x
fromRotationMatrixDenorm :: C a => Array (Int, Int) a -> T a Source #
The rotation matrix must be normalized. (I.e. no rotation with scaling) The computed quaternion is not normalized.
toComplexMatrix :: C a => T a -> Array (Int, Int) (T a) Source #
Map a quaternion to complex valued 2x2 matrix,
such that quaternion addition and multiplication
is mapped to matrix addition and multiplication.
The determinant of the matrix equals the squared quaternion norm (normSqr
).
Since complex numbers can be turned into real (orthogonal) matrices,
a quaternion could also be converted into a real matrix.
fromComplexMatrix :: C a => Array (Int, Int) (T a) -> T a Source #
Revert toComplexMatrix
.
Operations
scalarProduct :: C a => (a, a, a) -> (a, a, a) -> a Source #
crossProduct :: C a => (a, a, a) -> (a, a, a) -> (a, a, a) Source #
normSqr :: C a => T a -> a Source #
the same as NormedEuc.normSqr but with a simpler type class constraint
similarity :: C a => T a -> T a -> T a Source #
similarity mapping as needed for rotating 3D vectors
It holds
similarity (cos(a/2) +:: scaleImag (sin(a/2)) v) (0 +:: x) == (0 +:: y)
where y
results from rotating x
around the axis v
by the angle a
.
:: C a | |
=> a | For |
-> (a, a, a) | vector |
-> (a, a, a) | vector |
-> (a, a, a) |
Spherical Linear Interpolation
Can be generalized to any transcendent Hilbert space. In fact, we should also include the real part in the interpolation.