linear-1.23.2: Linear Algebra

Copyright | (C) 2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Linear.Projection

Description

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

Synopsis

- lookAt :: (Epsilon a, 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
- infinitePerspective :: Floating a => a -> a -> a -> M44 a
- inverseInfinitePerspective :: Floating 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
- ortho :: Fractional a => a -> a -> a -> a -> a -> a -> M44 a
- inverseOrtho :: Fractional a => a -> a -> a -> a -> a -> a -> M44 a

# Documentation

lookAt Source #

Arguments

:: (Epsilon a, Floating a) |
=> V3 a | Eye
-> V3 a | Center
-> V3 a | Up
-> M44 a |

Build a look at view matrix

perspective Source #

Arguments

:: Floating a |
=> a | FOV (y direction, in radians)
-> a | Aspect ratio
-> a | Near plane
-> a | Far plane
-> M44 a |

Build a matrix for a symmetric perspective-view frustum

inversePerspective Source #

Arguments

:: Floating a |
=> a | FOV (y direction, in radians)
-> a | Aspect ratio
-> a | Near plane
-> a | Far plane
-> M44 a |

Build an inverse perspective matrix

infinitePerspective Source #

Arguments

:: Floating a |
=> a | FOV (y direction, in radians)
-> a | Aspect Ratio
-> a | Near plane
-> M44 a |

Build a matrix for a symmetric perspective-view frustum with a far plane at infinite

inverseInfinitePerspective Source #

Arguments

:: Floating a |
=> a | FOV (y direction, in radians)
-> a | Aspect Ratio
-> a | Near plane
-> M44 a |

frustum Source #

Arguments

:: Floating a |
=> a | Left
-> a | Right
-> a | Bottom
-> a | Top
-> a | Near
-> a | Far
-> M44 a |

Build a perspective matrix per the classic `glFrustum` arguments.

inverseFrustum Source #

Arguments

:: Floating a |
=> a | Left
-> a | Right
-> a | Bottom
-> a | Top
-> a | Near
-> a | Far
-> M44 a |

ortho Source #

Arguments

:: 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) 1
    ortho 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

inverseOrtho Source #

Arguments

:: 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