Safe Haskell | None |
---|---|
Language | Haskell98 |
- class AbelianGroup g where
- vecSum :: AbelianGroup g => [g] -> g
- class MultSemiGroup r where
- class (AbelianGroup r, MultSemiGroup r) => Ring r
- semigroupProduct :: MultSemiGroup r => [r] -> r
- class LeftModule r m where
- class RightModule m r | m -> r, r -> m where
- class AbelianGroup (v a) => Vector a v where
- class Floating a => DotProd a v where
- class CrossProd v where
- normalize :: (Vector a v, DotProd a v) => v a -> v a
- distance :: (Vector a v, DotProd a v) => v a -> v a -> a
- angle :: (Vector a v, DotProd a v) => v a -> v a -> a
- angle' :: (Vector a v, UnitVector a v u, DotProd a v) => u a -> u a -> a
- class (Vector a v, DotProd a v) => UnitVector a v u | u -> v, v -> u where
- mkNormal :: v a -> u a
- toNormalUnsafe :: v a -> u a
- fromNormal :: u a -> v a
- fromNormalRadius :: a -> u a -> v a
- class Pointwise v where
- class Extend a u v where
- extendZero :: u a -> v a
- extendWith :: a -> u a -> v a
- trim :: v a -> u a
- class HasCoordinates v x | v -> x where
- class Dimension a where
- class Matrix m where
- class Tensor t v | t -> v where
- outer :: v -> v -> t
- class Diagonal s t | t -> s where
- diag :: s -> t
- class Determinant a m where
- det :: m -> a
- class Matrix (m a) => Orthogonal a m o | m -> o, o -> m where
- fromOrtho :: o a -> m a
- toOrthoUnsafe :: m a -> o a
- class (Vector a v, Orthogonal a n o, Diagonal (v a) (n a)) => Projective a v n o m p | m -> p, p -> m, p -> o, o -> p, p -> n, n -> p, p -> v, v -> p, n -> o, n -> v, v -> n where
- fromProjective :: p a -> m a
- toProjectiveUnsafe :: m a -> p a
- orthogonal :: o a -> p a
- linear :: n a -> p a
- translation :: v a -> p a
- scaling :: v a -> p a
- class (AbelianGroup m, Matrix m) => MatrixNorms a m where
- frobeniusNorm :: m -> a
- matrixDistance :: m -> m -> a
- operatorNorm :: m -> a
- data Vec2 a = Vec2 !a !a
- data Vec3 a = Vec3 !a !a !a
- data Vec4 a = Vec4 !a !a !a !a
- data Mat2 a = Mat2 !(Vec2 a) !(Vec2 a)
- data Mat3 a = Mat3 !(Vec3 a) !(Vec3 a) !(Vec3 a)
- data Mat4 a = Mat4 !(Vec4 a) !(Vec4 a) !(Vec4 a) !(Vec4 a)
- data Ortho2 a
- data Ortho3 a
- data Ortho4 a
- data Normal2 a
- data Normal3 a
- data Normal4 a
- data Proj3 a
- data Proj4 a
- mkVec2 :: (a, a) -> Vec2 a
- mkVec3 :: (a, a, a) -> Vec3 a
- mkVec4 :: (a, a, a, a) -> Vec4 a
- project :: (Vector a v, DotProd a v) => v a -> v a -> v a
- project' :: (Vector a v, UnitVector a v u, DotProd a v) => v a -> u a -> v a
- projectUnsafe :: (Vector a v, DotProd a v) => v a -> v a -> v a
- flipNormal :: UnitVector a v n => n a -> n a
- householder :: (Vector a v, UnitVector a v u, Matrix (m a), Vector a m, Tensor (m a) (v a)) => u a -> m a
- householderOrtho :: (Vector a v, UnitVector a v u, Matrix (m a), Vector a m, Tensor (m a) (v a), Orthogonal a m o) => u a -> o a
Documentation
class AbelianGroup g where Source
Floating a => AbelianGroup (Mat4 a) | |
Floating a => AbelianGroup (Mat3 a) | |
Floating a => AbelianGroup (Mat2 a) | |
Floating a => AbelianGroup (Vec4 a) | |
Floating a => AbelianGroup (Vec3 a) | |
Floating a => AbelianGroup (Vec2 a) | |
Floating a => AbelianGroup (Quaternion a) |
vecSum :: AbelianGroup g => [g] -> g Source
class MultSemiGroup r where Source
Floating a => MultSemiGroup (Proj4 a) | |
Floating a => MultSemiGroup (Proj3 a) | |
Floating a => MultSemiGroup (Ortho4 a) | |
Floating a => MultSemiGroup (Ortho3 a) | |
Floating a => MultSemiGroup (Ortho2 a) | |
Floating a => MultSemiGroup (Mat4 a) | |
Floating a => MultSemiGroup (Mat3 a) | |
Floating a => MultSemiGroup (Mat2 a) | |
Floating a => MultSemiGroup (UnitQuaternion a) | |
Num a => MultSemiGroup (Quaternion a) |
class (AbelianGroup r, MultSemiGroup r) => Ring r Source
semigroupProduct :: MultSemiGroup r => [r] -> r Source
class LeftModule r m where Source
Floating a => LeftModule (Mat4 a) (Vec4 a) | |
Floating a => LeftModule (Mat3 a) (Vec3 a) | |
Floating a => LeftModule (Mat2 a) (Vec2 a) | |
Num a => LeftModule (UnitQuaternion a) (Vec3 a) |
class RightModule m r | m -> r, r -> m where Source
Floating a => RightModule (Vec4 a) (Mat4 a) | |
Floating a => RightModule (Vec3 a) (Mat3 a) | |
Floating a => RightModule (Vec2 a) (Mat2 a) |
class AbelianGroup (v a) => Vector a v where Source
angle' :: (Vector a v, UnitVector a v u, DotProd a v) => u a -> u a -> a Source
the angle between two unit vectors
class (Vector a v, DotProd a v) => UnitVector a v u | u -> v, v -> u where Source
:: v a | |
-> u a | normalizes the input |
:: v a | |
-> u a | does not normalize the input! |
fromNormal :: u a -> v a Source
fromNormalRadius :: a -> u a -> v a Source
Floating a => UnitVector a Vec4 Normal4 | |
Floating a => UnitVector a Vec3 Normal3 | |
Floating a => UnitVector a Vec2 Normal2 | |
Floating a => UnitVector a Quaternion UnitQuaternion |
class Extend a u v where Source
conversion between vectors (and matrices) of different dimensions
:: u a | |
-> v a | example: |
:: a | |
-> u a | |
-> v a | example: |
:: v a | |
-> u a | example: |
class HasCoordinates v x | v -> x where Source
Nothing
Floating a => HasCoordinates (Vec4 a) a | |
Floating a => HasCoordinates (Vec3 a) a | |
Floating a => HasCoordinates (Vec2 a) a | |
Floating a => HasCoordinates (Mat4 a) (Vec4 a) | |
Floating a => HasCoordinates (Mat3 a) (Vec3 a) | |
Floating a => HasCoordinates (Mat2 a) (Vec2 a) |
class Dimension a where Source
Floating a => Dimension (Ortho4 a) | |
Floating a => Dimension (Ortho3 a) | |
Floating a => Dimension (Ortho2 a) | |
Floating a => Dimension (Normal4 a) | |
Floating a => Dimension (Normal3 a) | |
Floating a => Dimension (Normal2 a) | |
Floating a => Dimension (Mat4 a) | |
Floating a => Dimension (Mat3 a) | |
Floating a => Dimension (Mat2 a) | |
Floating a => Dimension (Vec4 a) | |
Floating a => Dimension (Vec3 a) | |
Floating a => Dimension (Vec2 a) |
class Determinant a m where Source
Floating a => Determinant a (Mat4 a) | |
Floating a => Determinant a (Mat3 a) | |
Floating a => Determinant a (Mat2 a) | |
Floating a => Determinant a (Ortho2 a) | |
Floating a => Determinant a (Ortho3 a) | |
Floating a => Determinant a (Ortho4 a) | |
Floating a => Determinant a (Vec2 a, Vec2 a) | |
Floating a => Determinant a (Vec3 a, Vec3 a, Vec3 a) |
class Matrix (m a) => Orthogonal a m o | m -> o, o -> m where Source
fromOrtho :: o a -> m a Source
toOrthoUnsafe :: m a -> o a Source
Floating a => Orthogonal a Mat4 Ortho4 | |
Floating a => Orthogonal a Mat3 Ortho3 | |
Floating a => Orthogonal a Mat2 Ortho2 |
class (Vector a v, Orthogonal a n o, Diagonal (v a) (n a)) => Projective a v n o m p | m -> p, p -> m, p -> o, o -> p, p -> n, n -> p, p -> v, v -> p, n -> o, n -> v, v -> n where Source
"Projective" matrices have the following form: the top left corner is an any matrix, the bottom right corner is 1, and the top-right column is zero. These describe the affine orthogonal transformation of the space one dimension less.
fromProjective :: p a -> m a Source
toProjectiveUnsafe :: m a -> p a Source
orthogonal :: o a -> p a Source
translation :: v a -> p a Source
class (AbelianGroup m, Matrix m) => MatrixNorms a m where Source
:: m | |
-> a | the frobenius norm (= euclidean norm in the space of matrices) |
:: m | |
-> m | |
-> a | euclidean distance in the space of matrices |
:: m | |
-> a | (euclidean) operator norm (not implemented yet) |
Floating a => MatrixNorms a (Mat4 a) | |
Floating a => MatrixNorms a (Mat3 a) | |
Floating a => MatrixNorms a (Mat2 a) |
Vec2 !a !a |
Floating a => DotProd a Vec2 | |
Floating a => Vector a Vec2 | |
Floating a => Extend a Vec2 Vec4 | |
Floating a => Extend a Vec2 Vec3 | |
Floating a => UnitVector a Vec2 Normal2 | |
Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 | |
Floating a => Interpolate a (Vec2 a) | |
Floating a => Determinant a (Vec2 a, Vec2 a) | |
Read a => Read (Vec2 a) | |
Show a => Show (Vec2 a) | |
(Floating a, Storable a) => Storable (Vec2 a) | |
(Floating a, Random a) => Random (Vec2 a) | |
Floating a => Dimension (Vec2 a) | |
Floating a => Pointwise (Vec2 a) | |
Floating a => AbelianGroup (Vec2 a) | |
Floating a => HasCoordinates (Vec2 a) a | |
Floating a => Tensor (Mat2 a) (Vec2 a) | |
Floating a => Diagonal (Vec2 a) (Mat2 a) | |
Floating a => HasCoordinates (Mat2 a) (Vec2 a) | |
Floating a => RightModule (Vec2 a) (Mat2 a) | |
Floating a => LeftModule (Mat2 a) (Vec2 a) | |
Floating a => GramSchmidt (Vec2 a, Vec2 a) | |
Typeable (* -> *) Vec2 |
Vec3 !a !a !a |
Floating a => DotProd a Vec3 | |
Floating a => Vector a Vec3 | |
Floating a => Extend a Vec3 Vec4 | |
Floating a => Extend a Vec2 Vec3 | |
Floating a => UnitVector a Vec3 Normal3 | |
Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 | |
Floating a => Interpolate a (Vec3 a) | |
Floating a => Determinant a (Vec3 a, Vec3 a, Vec3 a) | |
Read a => Read (Vec3 a) | |
Show a => Show (Vec3 a) | |
(Floating a, Storable a) => Storable (Vec3 a) | |
(Floating a, Random a) => Random (Vec3 a) | |
Floating a => Dimension (Vec3 a) | |
Num a => Pointwise (Vec3 a) | |
Floating a => CrossProd (Vec3 a) | |
Floating a => AbelianGroup (Vec3 a) | |
Floating a => HasCoordinates (Vec3 a) a | |
Floating a => Tensor (Mat3 a) (Vec3 a) | |
Floating a => Diagonal (Vec3 a) (Mat3 a) | |
Floating a => HasCoordinates (Mat3 a) (Vec3 a) | |
Floating a => RightModule (Vec3 a) (Mat3 a) | |
Floating a => LeftModule (Mat3 a) (Vec3 a) | |
Num a => LeftModule (UnitQuaternion a) (Vec3 a) | |
Floating a => GramSchmidt (Vec3 a, Vec3 a) | |
Typeable (* -> *) Vec3 | |
Floating a => GramSchmidt (Vec3 a, Vec3 a, Vec3 a) |
Vec4 !a !a !a !a |
Floating a => DotProd a Vec4 | |
Floating a => Vector a Vec4 | |
Floating a => Extend a Vec3 Vec4 | |
Floating a => Extend a Vec2 Vec4 | |
Floating a => UnitVector a Vec4 Normal4 | |
Floating a => Interpolate a (Vec4 a) | |
Read a => Read (Vec4 a) | |
Show a => Show (Vec4 a) | |
(Floating a, Storable a) => Storable (Vec4 a) | |
(Floating a, Random a) => Random (Vec4 a) | |
Floating a => Dimension (Vec4 a) | |
Num a => Pointwise (Vec4 a) | |
Floating a => AbelianGroup (Vec4 a) | |
Floating a => HasCoordinates (Vec4 a) a | |
Floating a => Tensor (Mat4 a) (Vec4 a) | |
Floating a => Diagonal (Vec4 a) (Mat4 a) | |
Floating a => HasCoordinates (Mat4 a) (Vec4 a) | |
Floating a => RightModule (Vec4 a) (Mat4 a) | |
Floating a => LeftModule (Mat4 a) (Vec4 a) | |
Floating a => GramSchmidt (Vec4 a, Vec4 a) | |
Typeable (* -> *) Vec4 | |
Floating a => GramSchmidt (Vec4 a, Vec4 a, Vec4 a) | |
Floating a => GramSchmidt (Vec4 a, Vec4 a, Vec4 a, Vec4 a) |
The components are row vectors
Floating a => Vector a Mat2 | |
Floating a => Orthogonal a Mat2 Ortho2 | |
Floating a => Extend a Mat2 Mat4 | |
Floating a => Extend a Mat2 Mat3 | |
Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 | |
Floating a => Determinant a (Mat2 a) | |
Floating a => MatrixNorms a (Mat2 a) | |
Read a => Read (Mat2 a) | |
Show a => Show (Mat2 a) | |
(Floating a, Storable a) => Storable (Mat2 a) | |
(Floating a, Random a) => Random (Mat2 a) | |
Floating a => Dimension (Mat2 a) | |
Floating a => Matrix (Mat2 a) | |
Floating a => Pointwise (Mat2 a) | |
Floating a => Ring (Mat2 a) | |
Floating a => MultSemiGroup (Mat2 a) | |
Floating a => AbelianGroup (Mat2 a) | |
Floating a => Tensor (Mat2 a) (Vec2 a) | |
Floating a => Diagonal (Vec2 a) (Mat2 a) | |
Floating a => HasCoordinates (Mat2 a) (Vec2 a) | |
Floating a => RightModule (Vec2 a) (Mat2 a) | |
Floating a => LeftModule (Mat2 a) (Vec2 a) |
Floating a => Vector a Mat3 | |
Floating a => Orthogonal a Mat3 Ortho3 | |
Floating a => Extend a Mat3 Mat4 | |
Floating a => Extend a Mat2 Mat3 | |
Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 | |
Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 | |
Floating a => Determinant a (Mat3 a) | |
Floating a => MatrixNorms a (Mat3 a) | |
Read a => Read (Mat3 a) | |
Show a => Show (Mat3 a) | |
(Floating a, Storable a) => Storable (Mat3 a) | |
(Floating a, Random a) => Random (Mat3 a) | |
Floating a => Dimension (Mat3 a) | |
Floating a => Matrix (Mat3 a) | |
Floating a => Pointwise (Mat3 a) | |
Floating a => Ring (Mat3 a) | |
Floating a => MultSemiGroup (Mat3 a) | |
Floating a => AbelianGroup (Mat3 a) | |
Floating a => Tensor (Mat3 a) (Vec3 a) | |
Floating a => Diagonal (Vec3 a) (Mat3 a) | |
Floating a => HasCoordinates (Mat3 a) (Vec3 a) | |
Floating a => RightModule (Vec3 a) (Mat3 a) | |
Floating a => LeftModule (Mat3 a) (Vec3 a) |
Floating a => Vector a Mat4 | |
Floating a => Orthogonal a Mat4 Ortho4 | |
Floating a => Extend a Mat3 Mat4 | |
Floating a => Extend a Mat2 Mat4 | |
Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 | |
Floating a => Determinant a (Mat4 a) | |
Floating a => MatrixNorms a (Mat4 a) | |
Read a => Read (Mat4 a) | |
Show a => Show (Mat4 a) | |
(Floating a, Storable a) => Storable (Mat4 a) | |
(Floating a, Random a) => Random (Mat4 a) | |
Floating a => Dimension (Mat4 a) | |
Floating a => Matrix (Mat4 a) | |
Floating a => Pointwise (Mat4 a) | |
Floating a => Ring (Mat4 a) | |
Floating a => MultSemiGroup (Mat4 a) | |
Floating a => AbelianGroup (Mat4 a) | |
Floating a => Tensor (Mat4 a) (Vec4 a) | |
Floating a => Diagonal (Vec4 a) (Mat4 a) | |
Floating a => HasCoordinates (Mat4 a) (Vec4 a) | |
Floating a => RightModule (Vec4 a) (Mat4 a) | |
Floating a => LeftModule (Mat4 a) (Vec4 a) |
Orthogonal matrices.
Note: the Random instances generates orthogonal matrices with determinant 1 (that is, orientation-preserving orthogonal transformations)!
Floating a => Orthogonal a Mat2 Ortho2 | |
Floating a => Projective a Vec2 Mat2 Ortho2 Mat3 Proj3 | |
Floating a => Determinant a (Ortho2 a) | |
Read a => Read (Ortho2 a) | |
Show a => Show (Ortho2 a) | |
(Floating a, Storable a) => Storable (Ortho2 a) | |
(Floating a, Ord a, Random a) => Random (Ortho2 a) | |
Floating a => Dimension (Ortho2 a) | |
Floating a => Matrix (Ortho2 a) | |
Floating a => MultSemiGroup (Ortho2 a) |
Floating a => Orthogonal a Mat3 Ortho3 | |
Floating a => Projective a Vec3 Mat3 Ortho3 Mat4 Proj4 | |
Floating a => Determinant a (Ortho3 a) | |
Read a => Read (Ortho3 a) | |
Show a => Show (Ortho3 a) | |
(Floating a, Storable a) => Storable (Ortho3 a) | |
(Floating a, Ord a, Random a) => Random (Ortho3 a) | |
Floating a => Dimension (Ortho3 a) | |
Floating a => Matrix (Ortho3 a) | |
Floating a => MultSemiGroup (Ortho3 a) |
Floating a => Orthogonal a Mat4 Ortho4 | |
Floating a => Determinant a (Ortho4 a) | |
Read a => Read (Ortho4 a) | |
Show a => Show (Ortho4 a) | |
(Floating a, Storable a) => Storable (Ortho4 a) | |
(Floating a, Ord a, Random a) => Random (Ortho4 a) | |
Floating a => Dimension (Ortho4 a) | |
Floating a => Matrix (Ortho4 a) | |
Floating a => MultSemiGroup (Ortho4 a) |
The assumption when dealing with these is always that they are of unit length. Also, interpolation works differently.
Floating a => DotProd a Normal2 | |
Floating a => UnitVector a Vec2 Normal2 | |
Floating a => Interpolate a (Normal2 a) | |
Read a => Read (Normal2 a) | |
Show a => Show (Normal2 a) | |
(Floating a, Storable a) => Storable (Normal2 a) | |
(Floating a, Random a, Ord a) => Random (Normal2 a) | |
Floating a => Dimension (Normal2 a) | |
Floating a => GramSchmidt (Normal2 a, Normal2 a) | |
Typeable (* -> *) Normal2 |
Floating a => DotProd a Normal3 | |
Floating a => UnitVector a Vec3 Normal3 | |
Floating a => Interpolate a (Normal3 a) | |
Read a => Read (Normal3 a) | |
Show a => Show (Normal3 a) | |
(Floating a, Storable a) => Storable (Normal3 a) | |
(Floating a, Random a, Ord a) => Random (Normal3 a) | |
Floating a => Dimension (Normal3 a) | |
Floating a => CrossProd (Normal3 a) | |
Floating a => GramSchmidt (Normal3 a, Normal3 a) | |
Typeable (* -> *) Normal3 | |
Floating a => GramSchmidt (Normal3 a, Normal3 a, Normal3 a) |
Floating a => DotProd a Normal4 | |
Floating a => UnitVector a Vec4 Normal4 | |
Floating a => Interpolate a (Normal4 a) | |
Read a => Read (Normal4 a) | |
Show a => Show (Normal4 a) | |
(Floating a, Storable a) => Storable (Normal4 a) | |
(Floating a, Random a, Ord a) => Random (Normal4 a) | |
Floating a => Dimension (Normal4 a) | |
Floating a => GramSchmidt (Normal4 a, Normal4 a) | |
Typeable (* -> *) Normal4 | |
Floating a => GramSchmidt (Normal4 a, Normal4 a, Normal4 a) | |
Floating a => GramSchmidt (Normal4 a, Normal4 a, Normal4 a, Normal4 a) |
Projective matrices, encoding affine transformations in dimension one less.
project' :: (Vector a v, UnitVector a v u, DotProd a v) => v a -> u a -> v a Source
Projects the first vector down to the hyperplane orthogonal to the second (unit) vector
projectUnsafe :: (Vector a v, DotProd a v) => v a -> v a -> v a Source
Direction (second argument) is assumed to be a unit vector!
flipNormal :: UnitVector a v n => n a -> n a Source
Since unit vectors are not a group, we need a separate function.
householder :: (Vector a v, UnitVector a v u, Matrix (m a), Vector a m, Tensor (m a) (v a)) => u a -> m a Source
Householder matrix, see http://en.wikipedia.org/wiki/Householder_transformation. In plain words, it is the reflection to the hyperplane orthogonal to the input vector.
householderOrtho :: (Vector a v, UnitVector a v u, Matrix (m a), Vector a m, Tensor (m a) (v a), Orthogonal a m o) => u a -> o a Source