numeric-prelude-0.1.1: An experimental alternative hierarchy of numeric type classesSource codeContentsIndex
Number.Quaternion
Portabilityportable (?)
Stabilityprovisional
Maintainernumericprelude@henning-thielemann.de
Contents
Cartesian form
Conversions
Operations
Description
Quaternions
Synopsis
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
data T a Source
Quaternions could be defined based on Complex numbers. However quaternions are often considered as real part and three imaginary parts.
show/hide Instances
C T
C a b => C a (T b)
C a b => C a (T b)
(C a, Sqr a b) => C a (T b)
Sqr a b => Sqr a (T b)
Eq a => Eq (T a)
Read a => Read (T a)
Show a => Show (T a)
C a => C (T a)
C a => C (T a)
C a => C (T a)
C a => C (T a)
fromReal :: C a => a -> T aSource
(+::) :: a -> (a, a, a) -> T aSource
Construct a quaternion from real and imaginary part.
Conversions
toRotationMatrix :: C a => T a -> Array (Int, Int) aSource
Let c be a unit quaternion, then it holds similarity c (0+::x) == toRotationMatrix c * x
fromRotationMatrix :: C a => Array (Int, Int) a -> T aSource
fromRotationMatrixDenorm :: C a => Array (Int, Int) a -> T aSource
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 aSource
Revert toComplexMatrix.
Operations
scalarProduct :: C a => (a, a, a) -> (a, a, a) -> aSource
crossProduct :: C a => (a, a, a) -> (a, a, a) -> (a, a, a)Source
conjugate :: C a => T a -> T aSource
The conjugate of a quaternion.
scale :: C a => a -> T a -> T aSource
Scale a quaternion by a real number.
norm :: C a => T a -> aSource
normSqr :: C a => T a -> aSource
the same as NormedEuc.normSqr but with a simpler type class constraint
normalize :: C a => T a -> T aSource
scale a quaternion into a unit quaternion
similarity :: C a => T a -> T a -> T aSource

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.

slerpSource
:: C a
=> aFor 0 return vector v, for 1 return vector w
-> (a, a, a)vector v, must be normalized
-> (a, a, a)vector w, must be normalized
-> (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.

Produced by Haddock version 2.4.2