HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulelinear-1.22Haskell2010

Linear.Projection

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

  • 9 values
  • Packagelinear-1.22
  • Exports9
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceProjection.hs
valueperspective
  1. :: Floating a
  2. => a

    FOV (y direction, in radians)

  3. -> a

    Aspect ratio

  4. -> a

    Near plane

  5. -> a

    Far plane

  6. -> M44 a
#

Build a matrix for a symmetric perspective-view frustum

valueinversePerspective
  1. :: Floating a
  2. => a

    FOV (y direction, in radians)

  3. -> a

    Aspect ratio

  4. -> a

    Near plane

  5. -> a

    Far plane

  6. -> M44 a
#

Build an inverse perspective matrix

valueinfinitePerspective
  1. :: Floating a
  2. => a

    FOV (y direction, in radians)

  3. -> a

    Aspect Ratio

  4. -> a

    Near plane

  5. -> M44 a
#

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

valuefrustum
  1. :: Floating a
  2. => a

    Left

  3. -> a

    Right

  4. -> a

    Bottom

  5. -> a

    Top

  6. -> a

    Near

  7. -> a

    Far

  8. -> M44 a
#

Build a perspective matrix per the classic glFrustum arguments.

valueortho
  1. :: Fractional a
  2. => a

    Left

  3. -> a

    Right

  4. -> a

    Bottom

  5. -> a

    Top

  6. -> a

    Near

  7. -> a

    Far

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

Example1 expression
ortho 1 2 3 4 5 6 !* V4 1 3 (-5) 1V4 (-1.0) (-1.0) (-1.0) 1.0
Example1 expression
ortho 1 2 3 4 5 6 !* V4 2 4 (-6) 1V4 1.0 1.0 1.0 1.0
valueinverseOrtho
  1. :: Fractional a
  2. => a

    Left

  3. -> a

    Right

  4. -> a

    Bottom

  5. -> a

    Top

  6. -> a

    Near

  7. -> a

    Far

  8. -> M44 a
#

Build an inverse orthographic perspective matrix from 6 clipping planes