Data.Vect.Float.Base
Synopsis
class AbelianGroup g where
 (&+) :: g -> g -> g (&-) :: g -> g -> g neg :: g -> g zero :: g
vecSum :: AbelianGroup g => [g] -> g
class MultSemiGroup r where
 (.*.) :: r -> r -> r one :: r
class (AbelianGroup r, MultSemiGroup r) => Ring r
semigroupProduct :: MultSemiGroup r => [r] -> r
class LeftModule r m where
 lmul :: r -> m -> m (*.) :: r -> m -> m
class RightModule m r where
 rmul :: m -> r -> m (.*) :: m -> r -> m
class AbelianGroup v => Vector v where
 mapVec :: (Float -> Float) -> v -> v scalarMul :: Float -> v -> v (*&) :: Float -> v -> v (&*) :: v -> Float -> v
class DotProd v where
 (&.) :: v -> v -> Float norm :: v -> Float normsqr :: v -> Float len :: v -> Float lensqr :: v -> Float dotprod :: v -> v -> Float
class CrossProd v where
 crossprod :: v -> v -> v (&^) :: v -> v -> v
normalize :: (Vector v, DotProd v) => v -> v
distance :: (Vector v, DotProd v) => v -> v -> Float
angle :: (Vector v, DotProd v) => v -> v -> Float
angle' :: (Vector v, UnitVector v u, DotProd v) => u -> u -> Float
class (Vector v, DotProd v) => UnitVector v u | v -> u, u -> v where
 mkNormal :: v -> u toNormalUnsafe :: v -> u fromNormal :: u -> v fromNormalRadius :: Float -> u -> v
class Pointwise v where
 pointwise :: v -> v -> v (&!) :: v -> v -> v
class Extend u v where
 extendZero :: u -> v extendWith :: Float -> u -> v trim :: v -> u
class HasCoordinates v x | v -> x where
 _1 :: v -> x _2 :: v -> x _3 :: v -> x _4 :: v -> x
class Dimension a where
 dim :: a -> Int
class Matrix m where
 transpose :: m -> m inverse :: m -> m idmtx :: m
class Tensor t v | t -> v where
 outer :: v -> v -> t
class Diagonal s t | t -> s where
 diag :: s -> t
class Determinant m where
 det :: m -> Float
class Matrix m => Orthogonal m o | m -> o, o -> m where
 fromOrtho :: o -> m toOrthoUnsafe :: m -> o
class (Vector v, Orthogonal n o, Diagonal v n) => Projective 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 -> m toProjectiveUnsafe :: m -> p orthogonal :: o -> p linear :: n -> p translation :: v -> p scaling :: v -> p
class (AbelianGroup m, Matrix m) => MatrixNorms m where
 frobeniusNorm :: m -> Float matrixDistance :: m -> m -> Float operatorNorm :: m -> Float
data Vec2 = Vec2 !Float !Float
data Vec3 = Vec3 !Float !Float !Float
data Vec4 = Vec4 !Float !Float !Float !Float
data Mat2 = Mat2 !Vec2 !Vec2
data Mat3 = Mat3 !Vec3 !Vec3 !Vec3
data Mat4 = Mat4 !Vec4 !Vec4 !Vec4 !Vec4
data Ortho2
data Ortho3
data Ortho4
data Normal2
data Normal3
data Normal4
data Proj3
data Proj4
mkVec2 :: (Float, Float) -> Vec2
mkVec3 :: (Float, Float, Float) -> Vec3
mkVec4 :: (Float, Float, Float, Float) -> Vec4
project :: (Vector v, DotProd v) => v -> v -> v
project' :: (Vector v, UnitVector v u, DotProd v) => v -> u -> v
projectUnsafe :: (Vector v, DotProd v) => v -> v -> v
flipNormal :: UnitVector v n => n -> n
householder :: (Vector v, UnitVector v u, Matrix m, Vector m, Tensor m v) => u -> m
householderOrtho :: (Vector v, UnitVector v u, Matrix m, Vector m, Tensor m v, Orthogonal m o) => u -> o
Documentation
 class AbelianGroup g where Source
Methods
 (&+) :: g -> g -> g Source
 (&-) :: g -> g -> g Source
 neg :: g -> g Source
 zero :: g Source
Instances
 AbelianGroup Mat4 AbelianGroup Mat3 AbelianGroup Mat2 AbelianGroup Vec4 AbelianGroup Vec3 AbelianGroup Vec2
 vecSum :: AbelianGroup g => [g] -> g Source
 class MultSemiGroup r where Source
Methods
 (.*.) :: r -> r -> r Source
 one :: r Source
Instances
 MultSemiGroup Proj4 MultSemiGroup Proj3 MultSemiGroup Ortho4 MultSemiGroup Ortho3 MultSemiGroup Ortho2 MultSemiGroup Mat4 MultSemiGroup Mat3 MultSemiGroup Mat2
 class (AbelianGroup r, MultSemiGroup r) => Ring r Source
Instances
 Ring Mat4 Ring Mat3 Ring Mat2
 semigroupProduct :: MultSemiGroup r => [r] -> r Source
 class LeftModule r m where Source
Methods
 lmul :: r -> m -> m Source
 (*.) :: r -> m -> m Source
Instances
 LeftModule Mat4 Vec4 LeftModule Mat4 Vec4 LeftModule Mat3 Vec3 LeftModule Mat3 Vec3 LeftModule Mat2 Vec2 LeftModule Mat2 Vec2
 class RightModule m r where Source
Methods
 rmul :: m -> r -> m Source
 (.*) :: m -> r -> m Source
Instances
 RightModule Vec4 Mat4 RightModule Vec4 Mat4 RightModule Vec3 Mat3 RightModule Vec3 Mat3 RightModule Vec2 Mat2 RightModule Vec2 Mat2
 class AbelianGroup v => Vector v where Source
Methods
 mapVec :: (Float -> Float) -> v -> v Source
 scalarMul :: Float -> v -> v Source
 (*&) :: Float -> v -> v Source
 (&*) :: v -> Float -> v Source
Instances
 Vector Mat4 Vector Mat3 Vector Mat2 Vector Vec4 Vector Vec3 Vector Vec2
 class DotProd v where Source
Methods
 (&.) :: v -> v -> Float Source
 norm :: v -> Float Source
 normsqr :: v -> Float Source
 len :: v -> Float Source
 lensqr :: v -> Float Source
 dotprod :: v -> v -> Float Source
Instances
 DotProd Normal4 DotProd Normal3 DotProd Normal2 DotProd Vec4 DotProd Vec3 DotProd Vec2
 class CrossProd v where Source
Cross product
Methods
 crossprod :: v -> v -> v Source
 (&^) :: v -> v -> v Source
Instances
 CrossProd Normal3 CrossProd Vec3
 normalize :: (Vector v, DotProd v) => v -> v Source
 distance :: (Vector v, DotProd v) => v -> v -> Float Source
 angle :: (Vector v, DotProd v) => v -> v -> Float Source
the angle between two vectors
 angle' :: (Vector v, UnitVector v u, DotProd v) => u -> u -> Float Source
the angle between two unit vectors
 class (Vector v, DotProd v) => UnitVector v u | v -> u, u -> v where Source
Methods
 mkNormal Source
 :: v -> u normalizes the input
 toNormalUnsafe Source
 :: v -> u does not normalize the input!
 fromNormal :: u -> v Source
 fromNormalRadius :: Float -> u -> v Source
Instances
 UnitVector Vec4 Normal4 UnitVector Vec4 Normal4 UnitVector Vec3 Normal3 UnitVector Vec3 Normal3 UnitVector Vec2 Normal2 UnitVector Vec2 Normal2
 class Pointwise v where Source
Pointwise multiplication
Methods
 pointwise :: v -> v -> v Source
 (&!) :: v -> v -> v Source
Instances
 Pointwise Vec4 Pointwise Vec3 Pointwise Vec2
 class Extend u v where Source
conversion between vectors (and matrices) of different dimensions
Methods
 extendZero Source
 :: u -> v example: extendZero (Vec2 5 6) = Vec4 5 6 0 0
 extendWith Source
 :: Float -> u -> v example: extendWith 1 (Vec2 5 6) = Vec4 5 6 1 1
 trim Source
 :: v -> u example: trim (Vec4 5 6 7 8) = Vec2 5 6
Instances
 Extend Mat3 Mat4 Extend Mat3 Mat4 Extend Mat2 Mat4 Extend Mat2 Mat4 Extend Mat2 Mat3 Extend Mat2 Mat3 Extend Vec3 Vec4 Extend Vec3 Vec4 Extend Vec2 Vec4 Extend Vec2 Vec4 Extend Vec2 Vec3 Extend Vec2 Vec3
 class HasCoordinates v x | v -> x where Source
Methods
 _1 :: v -> x Source
 _2 :: v -> x Source
 _3 :: v -> x Source
 _4 :: v -> x Source
Instances
 HasCoordinates Mat4 Vec4 HasCoordinates Mat4 Vec4 HasCoordinates Mat3 Vec3 HasCoordinates Mat3 Vec3 HasCoordinates Mat2 Vec2 HasCoordinates Mat2 Vec2 HasCoordinates Vec4 Float HasCoordinates Vec4 Float HasCoordinates Vec3 Float HasCoordinates Vec3 Float HasCoordinates Vec2 Float HasCoordinates Vec2 Float
 class Dimension a where Source
Methods
 dim :: a -> Int Source
Instances
 Dimension Ortho4 Dimension Ortho3 Dimension Ortho2 Dimension Normal4 Dimension Normal3 Dimension Normal2 Dimension Mat4 Dimension Mat3 Dimension Mat2 Dimension Vec4 Dimension Vec3 Dimension Vec2
 class Matrix m where Source
Methods
 transpose :: m -> m Source
 inverse :: m -> m Source
 idmtx :: m Source
Instances
 Matrix Proj4 Matrix Proj3 Matrix Ortho4 Matrix Ortho3 Matrix Ortho2 Matrix Mat4 Matrix Mat3 Matrix Mat2
 class Tensor t v | t -> v where Source
Outer product (could be unified with Diagonal?)
Methods
 outer :: v -> v -> t Source
Instances
 Tensor Mat4 Vec4 Tensor Mat4 Vec4 Tensor Mat3 Vec3 Tensor Mat3 Vec3 Tensor Mat2 Vec2 Tensor Mat2 Vec2
 class Diagonal s t | t -> s where Source
makes a diagonal matrix from a vector
Methods
 diag :: s -> t Source
Instances
 Diagonal Vec4 Mat4 Diagonal Vec4 Mat4 Diagonal Vec3 Mat3 Diagonal Vec3 Mat3 Diagonal Vec2 Mat2 Diagonal Vec2 Mat2
 class Determinant m where Source
Methods
 det :: m -> Float Source
Instances
 Determinant Ortho4 Determinant Ortho3 Determinant Ortho2 Determinant Mat4 Determinant Mat3 Determinant Mat2 Determinant ((,) Vec2 Vec2) Determinant ((,,) Vec3 Vec3 Vec3)
 class Matrix m => Orthogonal m o | m -> o, o -> m where Source
Methods
 fromOrtho :: o -> m Source
 toOrthoUnsafe :: m -> o Source
Instances
 Orthogonal Mat4 Ortho4 Orthogonal Mat4 Ortho4 Orthogonal Mat3 Ortho3 Orthogonal Mat3 Ortho3 Orthogonal Mat2 Ortho2 Orthogonal Mat2 Ortho2
 class (Vector v, Orthogonal n o, Diagonal v n) => Projective 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.
Methods
 fromProjective :: p -> m Source
 toProjectiveUnsafe :: m -> p Source
 orthogonal :: o -> p Source
 linear :: n -> p Source
 translation :: v -> p Source
 scaling :: v -> p Source
Instances
 Projective Vec3 Mat3 Ortho3 Mat4 Proj4 Projective Vec3 Mat3 Ortho3 Mat4 Proj4 Projective Vec3 Mat3 Ortho3 Mat4 Proj4 Projective Vec3 Mat3 Ortho3 Mat4 Proj4 Projective Vec3 Mat3 Ortho3 Mat4 Proj4 Projective Vec2 Mat2 Ortho2 Mat3 Proj3 Projective Vec2 Mat2 Ortho2 Mat3 Proj3 Projective Vec2 Mat2 Ortho2 Mat3 Proj3 Projective Vec2 Mat2 Ortho2 Mat3 Proj3 Projective Vec2 Mat2 Ortho2 Mat3 Proj3
 class (AbelianGroup m, Matrix m) => MatrixNorms m where Source
Methods
 frobeniusNorm Source
 :: m -> Float the frobenius norm (= euclidean norm in the space of matrices)
 matrixDistance Source
 :: m -> m -> Float euclidean distance in the space of matrices
 operatorNorm Source
 :: m -> Float (euclidean) operator norm (not implemented yet)
Instances
 MatrixNorms Mat4 MatrixNorms Mat3 MatrixNorms Mat2
 data Vec2 Source
Constructors
 Vec2 !Float !Float
Instances
 Read Vec2 Show Vec2 Uniform Vec2 Vertex Vec2 TexCoord Vec2 Storable Vec2 Random Vec2 Dimension Vec2 Pointwise Vec2 DotProd Vec2 Vector Vec2 AbelianGroup Vec2 Interpolate Vec2 VertexAttrib' Vec2 Tensor Mat2 Vec2 Diagonal Vec2 Mat2 Extend Vec2 Vec4 Extend Vec2 Vec3 HasCoordinates Mat2 Vec2 HasCoordinates Vec2 Float UnitVector Vec2 Normal2 RightModule Vec2 Mat2 LeftModule Mat2 Vec2 Projective Vec2 Mat2 Ortho2 Mat3 Proj3
 data Vec3 Source
Constructors
 Vec3 !Float !Float !Float
Instances
 Read Vec3 Show Vec3 Uniform Vec3 Vertex Vec3 TexCoord Vec3 Normal Vec3 Color Vec3 SecondaryColor Vec3 Storable Vec3 Random Vec3 Dimension Vec3 Pointwise Vec3 CrossProd Vec3 DotProd Vec3 Vector Vec3 AbelianGroup Vec3 Interpolate Vec3 VertexAttrib' Vec3 Tensor Mat3 Vec3 Diagonal Vec3 Mat3 Extend Vec3 Vec4 Extend Vec2 Vec3 HasCoordinates Mat3 Vec3 HasCoordinates Vec3 Float UnitVector Vec3 Normal3 RightModule Vec3 Mat3 LeftModule Mat3 Vec3 Projective Vec3 Mat3 Ortho3 Mat4 Proj4
 data Vec4 Source
Constructors
 Vec4 !Float !Float !Float !Float
Instances
 Read Vec4 Show Vec4 Uniform Vec4 Vertex Vec4 TexCoord Vec4 Color Vec4 Storable Vec4 Random Vec4 Dimension Vec4 Pointwise Vec4 DotProd Vec4 Vector Vec4 AbelianGroup Vec4 Interpolate Vec4 VertexAttrib' Vec4 Tensor Mat4 Vec4 Diagonal Vec4 Mat4 Extend Vec3 Vec4 Extend Vec2 Vec4 HasCoordinates Mat4 Vec4 HasCoordinates Vec4 Float UnitVector Vec4 Normal4 RightModule Vec4 Mat4 LeftModule Mat4 Vec4
 data Mat2 Source
The components are row vectors
Constructors
 Mat2 !Vec2 !Vec2
Instances
 Read Mat2 Show Mat2 Storable Mat2 Random Mat2 Dimension Mat2 Determinant Mat2 MatrixNorms Mat2 Matrix Mat2 Vector Mat2 Ring Mat2 MultSemiGroup Mat2 AbelianGroup Mat2 ToOpenGLMatrix Mat2 Tensor Mat2 Vec2 Orthogonal Mat2 Ortho2 Diagonal Vec2 Mat2 Extend Mat2 Mat4 Extend Mat2 Mat3 HasCoordinates Mat2 Vec2 RightModule Vec2 Mat2 LeftModule Mat2 Vec2 Projective Vec2 Mat2 Ortho2 Mat3 Proj3
 data Mat3 Source
Constructors
 Mat3 !Vec3 !Vec3 !Vec3
Instances
 Read Mat3 Show Mat3 Storable Mat3 Random Mat3 Dimension Mat3 Determinant Mat3 MatrixNorms Mat3 Matrix Mat3 Vector Mat3 Ring Mat3 MultSemiGroup Mat3 AbelianGroup Mat3 ToOpenGLMatrix Mat3 Tensor Mat3 Vec3 Orthogonal Mat3 Ortho3 Diagonal Vec3 Mat3 Extend Mat3 Mat4 Extend Mat2 Mat3 HasCoordinates Mat3 Vec3 RightModule Vec3 Mat3 LeftModule Mat3 Vec3 Projective Vec3 Mat3 Ortho3 Mat4 Proj4 Projective Vec2 Mat2 Ortho2 Mat3 Proj3
 data Mat4 Source
Constructors
 Mat4 !Vec4 !Vec4 !Vec4 !Vec4
Instances
 Read Mat4 Show Mat4 Storable Mat4 Random Mat4 Dimension Mat4 Determinant Mat4 MatrixNorms Mat4 Matrix Mat4 Vector Mat4 Ring Mat4 MultSemiGroup Mat4 AbelianGroup Mat4 FromOpenGLMatrix Mat4 ToOpenGLMatrix Mat4 Tensor Mat4 Vec4 Orthogonal Mat4 Ortho4 Diagonal Vec4 Mat4 Extend Mat3 Mat4 Extend Mat2 Mat4 HasCoordinates Mat4 Vec4 RightModule Vec4 Mat4 LeftModule Mat4 Vec4 Projective Vec3 Mat3 Ortho3 Mat4 Proj4
 data Ortho2 Source

Orthogonal matrices.

Note: the Random instances generates orthogonal matrices with determinant 1 (that is, orientation-preserving orthogonal transformations)!

Instances
 Read Ortho2 Show Ortho2 Storable Ortho2 Random Ortho2 Dimension Ortho2 Determinant Ortho2 Matrix Ortho2 MultSemiGroup Ortho2 ToOpenGLMatrix Ortho2 Orthogonal Mat2 Ortho2 Projective Vec2 Mat2 Ortho2 Mat3 Proj3
 data Ortho3 Source
Instances
 Read Ortho3 Show Ortho3 Storable Ortho3 Random Ortho3 Dimension Ortho3 Determinant Ortho3 Matrix Ortho3 MultSemiGroup Ortho3 ToOpenGLMatrix Ortho3 Orthogonal Mat3 Ortho3 Projective Vec3 Mat3 Ortho3 Mat4 Proj4
 data Ortho4 Source
Instances
 Read Ortho4 Show Ortho4 Storable Ortho4 Random Ortho4 Dimension Ortho4 Determinant Ortho4 Matrix Ortho4 MultSemiGroup Ortho4 ToOpenGLMatrix Ortho4 Orthogonal Mat4 Ortho4
 data Normal2 Source
The assumption when dealing with these is always that they are of unit length. Also, interpolation works differently.
Instances
 Read Normal2 Show Normal2 Storable Normal2 Random Normal2 Dimension Normal2 DotProd Normal2 Interpolate Normal2 VertexAttrib' Normal2 UnitVector Vec2 Normal2
 data Normal3 Source
Instances
 Read Normal3 Show Normal3 Normal Normal3 Storable Normal3 Random Normal3 Dimension Normal3 CrossProd Normal3 DotProd Normal3 Interpolate Normal3 VertexAttrib' Normal3 UnitVector Vec3 Normal3
 data Normal4 Source
Instances
 Read Normal4 Show Normal4 Storable Normal4 Random Normal4 Dimension Normal4 DotProd Normal4 VertexAttrib' Normal4 UnitVector Vec4 Normal4
 data Proj3 Source
Projective matrices, encoding affine transformations in dimension one less.
Instances
 Read Proj3 Show Proj3 Storable Proj3 Matrix Proj3 MultSemiGroup Proj3 ToOpenGLMatrix Proj3 Projective Vec2 Mat2 Ortho2 Mat3 Proj3
 data Proj4 Source
Instances
 Read Proj4 Show Proj4 Storable Proj4 Matrix Proj4 MultSemiGroup Proj4 ToOpenGLMatrix Proj4 Projective Vec3 Mat3 Ortho3 Mat4 Proj4
 mkVec2 :: (Float, Float) -> Vec2 Source
 mkVec3 :: (Float, Float, Float) -> Vec3 Source
 mkVec4 :: (Float, Float, Float, Float) -> Vec4 Source
 project :: (Vector v, DotProd v) => v -> v -> v Source
 project' :: (Vector v, UnitVector v u, DotProd v) => v -> u -> v Source
Projects the first vector onto the direction of the second (unit) vector
 projectUnsafe :: (Vector v, DotProd v) => v -> v -> v Source
Direction (second argument) is assumed to be a unit vector!
 flipNormal :: UnitVector v n => n -> n Source
Since unit vectors are not a group, we need a separate function.
 householder :: (Vector v, UnitVector v u, Matrix m, Vector m, Tensor m v) => u -> m 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 v, UnitVector v u, Matrix m, Vector m, Tensor m v, Orthogonal m o) => u -> o Source