Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for working with 3-dimensional homogeneous coordinates. This includes common projection matrices: e.g. perspective/orthographic transformation matrices.
Analytically derived inverses are also supplied, because they can be much more accurate in practice than computing them through general purpose means
Adapted from Linear.Projection
Synopsis
- m43_to_m44 :: Num a => M43 a -> M44 a
- vector :: Num a => V3 a -> V4 a
- point :: Num a => V3 a -> V4 a
- normalizePoint :: Fractional a => V4 a -> V3 a
- m33_to_m44 :: Num a => M33 a -> M44 a
- translation :: (Vec t, R3 t, R4 v) => Lens' (t (v a)) (V3 a)
- mkTransformationMat :: Num a => M33 a -> V3 a -> M44 a
- mkTransformation :: Num a => Quaternion a -> V3 a -> M44 a
- lookAt :: Floating a => V3 a -> V3 a -> V3 a -> M44 a
- perspective :: Floating a => a -> a -> a -> a -> M44 a
- inversePerspective :: Floating a => a -> a -> a -> a -> M44 a
- frustum :: Floating a => a -> a -> a -> a -> a -> a -> M44 a
- inverseFrustum :: Floating a => a -> a -> a -> a -> a -> a -> M44 a
- infinitePerspective :: Floating a => a -> a -> a -> M44 a
- inverseInfinitePerspective :: Floating a => a -> a -> a -> M44 a
- ortho :: Fractional a => a -> a -> a -> a -> a -> a -> M44 a
- inverseOrtho :: Fractional a => a -> a -> a -> a -> a -> a -> M44 a
Documentation
m43_to_m44 :: Num a => M43 a -> M44 a Source #
Convert from a 4x3 matrix to a 4x4 matrix, extending it with the [ 0 0 0 1 ]
column vector
vector :: Num a => V3 a -> V4 a Source #
Convert a 3-dimensional affine vector into a 4-dimensional homogeneous vector,
i.e. sets the w
coordinate to 0.
point :: Num a => V3 a -> V4 a Source #
Convert a 3-dimensional affine point into a 4-dimensional homogeneous vector,
i.e. sets the w
coordinate to 1.
normalizePoint :: Fractional a => V4 a -> V3 a Source #
Convert 4-dimensional projective coordinates to a 3-dimensional
point. This operation may be denoted, euclidean [x:y:z:w] = (x/w,
y/w, z/w)
where the projective, homogeneous, coordinate
[x:y:z:w]
is one of many associated with a single point (x/w,
y/w, z/w)
.
m33_to_m44 :: Num a => M33 a -> M44 a Source #
Convert a 3x3 matrix to a 4x4 matrix extending it with 0's in the new row and column.
translation :: (Vec t, R3 t, R4 v) => Lens' (t (v a)) (V3 a) Source #
Extract the translation vector (first three entries of the last column) from a 3x4 or 4x4 matrix.
mkTransformationMat :: Num a => M33 a -> V3 a -> M44 a Source #
Build a transformation matrix from a rotation matrix and a translation vector.
mkTransformation :: Num a => Quaternion a -> V3 a -> M44 a Source #
Build a transformation matrix from a rotation expressed as a
Quaternion
and a translation vector.
Build a matrix for a symmetric perspective-view frustum
Build an inverse perspective matrix
Build a perspective matrix per the classic glFrustum
arguments.
Build a matrix for a symmetric perspective-view frustum with a far plane at infinite
:: Fractional a | |
=> a | Left |
-> a | Right |
-> a | Bottom |
-> a | Top |
-> a | Near |
-> a | Far |
-> M44 a |
Build an orthographic perspective matrix from 6 clipping planes. This matrix takes the region delimited by these planes and maps it to normalized device coordinates between [-1,1]
This call is designed to mimic the parameters to the OpenGL glOrtho
call, so it has a slightly strange convention: Notably: the near and
far planes are negated.
Consequently:
ortho
l r b t n f !*V4
l b (-n) 1 =V4
(-1) (-1) (-1) 1ortho
l r b t n f !*V4
r t (-f) 1 =V4
1 1 1 1
Examples:
>>>
ortho 1 2 3 4 5 6 !* V4 1 3 (-5) 1
V4 (-1.0) (-1.0) (-1.0) 1.0
>>>
ortho 1 2 3 4 5 6 !* V4 2 4 (-6) 1
V4 1.0 1.0 1.0 1.0
:: Fractional a | |
=> a | Left |
-> a | Right |
-> a | Bottom |
-> a | Top |
-> a | Near |
-> a | Far |
-> M44 a |
Build an inverse orthographic perspective matrix from 6 clipping planes