GLMatrix- Utilities for working with OpenGL matrices

Safe HaskellNone



Modified from / based on: https:github.comkigtomtegebrablobmasterTomtegebraMatrix.hs



translationMatrix :: Vector3 -> Matrix4x4Source

Creates the translation matrix that translates points by the given vector.

frustumMatrix :: GLfloat -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> Matrix4x4Source

Creates a frustumMatrix from the given left, right, bottom, top, znear and zfar values for the view frustum.

identityMatrix :: Matrix4x4Source

The Matrix4x4 identity matrix.

matrixMulVec :: Matrix4x4 -> Vector4 -> Vector4Source

Multiplies a vector by a matrix.

matrix4x4To3x3 :: Matrix4x4 -> Matrix3x3Source

Returns the upper-left 3x3 matrix of a 4x4 matrix.

matrix3x3To4x4 :: Matrix3x3 -> Matrix4x4Source

Pads the 3x3 matrix to a 4x4 matrix with a 1 in bottom right corner and 0 elsewhere.

invertMatrix4x4ON :: Matrix4x4 -> Matrix4x4Source

Inverts a 4x4 orthonormal matrix with the special case trick.

scalingMatrix :: Vector3 -> Matrix4x4Source

Creates the scaling matrix that scales points by the factors given by the vector components.

lookAtMatrixG :: Vector3 -> Vector3 -> Vector3 -> Matrix4x4Source

Creates a lookAt matrix from three vectors: the eye position, the point the eye is looking at and the up vector of the eye.

perspectiveMatrix :: GLfloat -> GLfloat -> GLfloat -> GLfloat -> Matrix4x4Source

Creates a perspective projection matrix for the given field-of-view, screen aspect ratio, znear and zfar.

addVec :: [GLfloat] -> [GLfloat] -> [GLfloat]Source

Adds two vectors together.

type Matrix4x4 = [[GLfloat]]Source

4x4 Matrix in the OpenGL orientation: translation column is the last 4 elements.

type Matrix3x3 = [[GLfloat]]Source

3x3 Matrix in the OpenGL orientation.

type Vector4 = [GLfloat]Source

Four element GLfloat vector.

type Vector3 = [GLfloat]Source

Three element GLfloat vector.