numeric-prelude-0.4.3.2: An experimental alternative hierarchy of numeric type classes

Maintainernumericprelude@henning-thielemann.de
Stabilityprovisional
Portabilityportable (?)
Safe HaskellNone
LanguageHaskell98

Number.Quaternion

Contents

Description

Quaternions

Synopsis

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.

Instances
C T Source # 
Instance details

Defined in Number.Quaternion

Methods

zero :: C a => T a Source #

(<+>) :: C a => T a -> T a -> T a Source #

(*>) :: C a => a -> T a -> T a Source #

C a b => C a (T b) Source #

The '(*>)' method can't replace scale because it requires the Algebra.Module constraint

Instance details

Defined in Number.Quaternion

Methods

(*>) :: a -> T b -> T b Source #

C a b => C a (T b) Source # 
Instance details

Defined in Number.Quaternion

(C a, Sqr a b) => C a (T b) Source # 
Instance details

Defined in Number.Quaternion

Methods

norm :: T b -> a Source #

Sqr a b => Sqr a (T b) Source # 
Instance details

Defined in Number.Quaternion

Methods

normSqr :: T b -> a Source #

Eq a => Eq (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

(==) :: T a -> T a -> Bool #

(/=) :: T a -> T a -> Bool #

Read a => Read (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

readsPrec :: Int -> ReadS (T a) #

readList :: ReadS [T a] #

readPrec :: ReadPrec (T a) #

readListPrec :: ReadPrec [T a] #

Show a => Show (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

showsPrec :: Int -> T a -> ShowS #

show :: T a -> String #

showList :: [T a] -> ShowS #

C a => C (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

zero :: T a Source #

(+) :: T a -> T a -> T a Source #

(-) :: T a -> T a -> T a Source #

negate :: T a -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

isZero :: T a -> Bool Source #

C a => C (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

(*) :: T a -> T a -> T a Source #

one :: T a Source #

fromInteger :: Integer -> T a Source #

(^) :: T a -> Integer -> T a Source #

C a => C (T a) Source # 
Instance details

Defined in Number.Quaternion

Methods

(/) :: T a -> T a -> T a Source #

recip :: T a -> T a Source #

fromRational' :: Rational -> T a Source #

(^-) :: T a -> Integer -> T a Source #

fromReal :: C a => a -> T a Source #

(+::) :: a -> (a, a, a) -> T a infix 6 Source #

Construct a quaternion from real and imaginary part.

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 #

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 #

conjugate :: C a => T a -> T a Source #

The conjugate of a quaternion.

scale :: C a => a -> T a -> T a Source #

Scale a quaternion by a real number.

norm :: C a => T a -> a Source #

normSqr :: C a => T a -> a Source #

the same as NormedEuc.normSqr but with a simpler type class constraint

normalize :: C a => T a -> T a Source #

scale a quaternion into a unit quaternion

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.

slerp Source #

Arguments

:: C a 
=> a

For 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.