gi-graphene-1.0.8: Graphene bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Graphene.Structs.Matrix

Contents

- Exported types
- Methods
  - alloc
  - decompose
  - determinant
  - equal
  - equalFast
  - free
  - getRow
  - getValue
  - getXScale
  - getXTranslation
  - getYScale
  - getYTranslation
  - getZScale
  - getZTranslation
  - initFrom2d
  - initFromFloat
  - initFromMatrix
  - initFromVec4
  - initFrustum
  - initIdentity
  - initLookAt
  - initOrtho
  - initPerspective
  - initRotate
  - initScale
  - initSkew
  - initTranslate
  - interpolate
  - inverse
  - is2d
  - isBackfaceVisible
  - isIdentity
  - isSingular
  - multiply
  - near
  - normalize
  - perspective
  - print
  - projectPoint
  - projectRect
  - projectRectBounds
  - rotate
  - rotateEuler
  - rotateQuaternion
  - rotateX
  - rotateY
  - rotateZ
  - scale
  - skewXy
  - skewXz
  - skewYz
  - to2d
  - transformBounds
  - transformBox
  - transformPoint
  - transformPoint3d
  - transformRay
  - transformRect
  - transformSphere
  - transformVec3
  - transformVec4
  - translate
  - transpose
  - unprojectPoint3d
  - untransformBounds
  - untransformPoint

Description

A structure capable of holding a 4x4 matrix.

The contents of the `Matrix` structure are private and should never be accessed directly.

Synopsis

- newtype Matrix = Matrix (ManagedPtr Matrix)
- newZeroMatrix :: MonadIO m => m Matrix
- matrixAlloc :: (HasCallStack, MonadIO m) => m Matrix
- matrixDecompose :: (HasCallStack, MonadIO m) => Matrix -> m (Bool, Vec3, Vec3, Quaternion, Vec3, Vec4)
- matrixDeterminant :: (HasCallStack, MonadIO m) => Matrix -> m Float
- matrixEqual :: (HasCallStack, MonadIO m) => Matrix -> Matrix -> m Bool
- matrixEqualFast :: (HasCallStack, MonadIO m) => Matrix -> Matrix -> m Bool
- matrixFree :: (HasCallStack, MonadIO m) => Matrix -> m ()
- matrixGetRow :: (HasCallStack, MonadIO m) => Matrix -> Word32 -> m Vec4
- matrixGetValue :: (HasCallStack, MonadIO m) => Matrix -> Word32 -> Word32 -> m Float
- matrixGetXScale :: (HasCallStack, MonadIO m) => Matrix -> m Float
- matrixGetXTranslation :: (HasCallStack, MonadIO m) => Matrix -> m Float
- matrixGetYScale :: (HasCallStack, MonadIO m) => Matrix -> m Float
- matrixGetYTranslation :: (HasCallStack, MonadIO m) => Matrix -> m Float
- matrixGetZScale :: (HasCallStack, MonadIO m) => Matrix -> m Float
- matrixGetZTranslation :: (HasCallStack, MonadIO m) => Matrix -> m Float
- matrixInitFrom2d :: (HasCallStack, MonadIO m) => Matrix -> Double -> Double -> Double -> Double -> Double -> Double -> m Matrix
- matrixInitFromFloat :: (HasCallStack, MonadIO m) => Matrix -> [Float] -> m Matrix
- matrixInitFromMatrix :: (HasCallStack, MonadIO m) => Matrix -> Matrix -> m Matrix
- matrixInitFromVec4 :: (HasCallStack, MonadIO m) => Matrix -> Vec4 -> Vec4 -> Vec4 -> Vec4 -> m Matrix
- matrixInitFrustum :: (HasCallStack, MonadIO m) => Matrix -> Float -> Float -> Float -> Float -> Float -> Float -> m Matrix
- matrixInitIdentity :: (HasCallStack, MonadIO m) => Matrix -> m Matrix
- matrixInitLookAt :: (HasCallStack, MonadIO m) => Matrix -> Vec3 -> Vec3 -> Vec3 -> m Matrix
- matrixInitOrtho :: (HasCallStack, MonadIO m) => Matrix -> Float -> Float -> Float -> Float -> Float -> Float -> m Matrix
- matrixInitPerspective :: (HasCallStack, MonadIO m) => Matrix -> Float -> Float -> Float -> Float -> m Matrix
- matrixInitRotate :: (HasCallStack, MonadIO m) => Matrix -> Float -> Vec3 -> m Matrix
- matrixInitScale :: (HasCallStack, MonadIO m) => Matrix -> Float -> Float -> Float -> m Matrix
- matrixInitSkew :: (HasCallStack, MonadIO m) => Matrix -> Float -> Float -> m Matrix
- matrixInitTranslate :: (HasCallStack, MonadIO m) => Matrix -> Point3D -> m Matrix
- matrixInterpolate :: (HasCallStack, MonadIO m) => Matrix -> Matrix -> Double -> m Matrix
- matrixInverse :: (HasCallStack, MonadIO m) => Matrix -> m (Bool, Matrix)
- matrixIs2d :: (HasCallStack, MonadIO m) => Matrix -> m Bool
- matrixIsBackfaceVisible :: (HasCallStack, MonadIO m) => Matrix -> m Bool
- matrixIsIdentity :: (HasCallStack, MonadIO m) => Matrix -> m Bool
- matrixIsSingular :: (HasCallStack, MonadIO m) => Matrix -> m Bool
- matrixMultiply :: (HasCallStack, MonadIO m) => Matrix -> Matrix -> m Matrix
- matrixNear :: (HasCallStack, MonadIO m) => Matrix -> Matrix -> Float -> m Bool
- matrixNormalize :: (HasCallStack, MonadIO m) => Matrix -> m Matrix
- matrixPerspective :: (HasCallStack, MonadIO m) => Matrix -> Float -> m Matrix
- matrixPrint :: (HasCallStack, MonadIO m) => Matrix -> m ()
- matrixProjectPoint :: (HasCallStack, MonadIO m) => Matrix -> Point -> m Point
- matrixProjectRect :: (HasCallStack, MonadIO m) => Matrix -> Rect -> m Quad
- matrixProjectRectBounds :: (HasCallStack, MonadIO m) => Matrix -> Rect -> m Rect
- matrixRotate :: (HasCallStack, MonadIO m) => Matrix -> Float -> Vec3 -> m ()
- matrixRotateEuler :: (HasCallStack, MonadIO m) => Matrix -> Euler -> m ()
- matrixRotateQuaternion :: (HasCallStack, MonadIO m) => Matrix -> Quaternion -> m ()
- matrixRotateX :: (HasCallStack, MonadIO m) => Matrix -> Float -> m ()
- matrixRotateY :: (HasCallStack, MonadIO m) => Matrix -> Float -> m ()
- matrixRotateZ :: (HasCallStack, MonadIO m) => Matrix -> Float -> m ()
- matrixScale :: (HasCallStack, MonadIO m) => Matrix -> Float -> Float -> Float -> m ()
- matrixSkewXy :: (HasCallStack, MonadIO m) => Matrix -> Float -> m ()
- matrixSkewXz :: (HasCallStack, MonadIO m) => Matrix -> Float -> m ()
- matrixSkewYz :: (HasCallStack, MonadIO m) => Matrix -> Float -> m ()
- matrixTo2d :: (HasCallStack, MonadIO m) => Matrix -> m (Bool, Double, Double, Double, Double, Double, Double)
- matrixTransformBounds :: (HasCallStack, MonadIO m) => Matrix -> Rect -> m Rect
- matrixTransformBox :: (HasCallStack, MonadIO m) => Matrix -> Box -> m Box
- matrixTransformPoint :: (HasCallStack, MonadIO m) => Matrix -> Point -> m Point
- matrixTransformPoint3d :: (HasCallStack, MonadIO m) => Matrix -> Point3D -> m Point3D
- matrixTransformRay :: (HasCallStack, MonadIO m) => Matrix -> Ray -> m Ray
- matrixTransformRect :: (HasCallStack, MonadIO m) => Matrix -> Rect -> m Quad
- matrixTransformSphere :: (HasCallStack, MonadIO m) => Matrix -> Sphere -> m Sphere
- matrixTransformVec3 :: (HasCallStack, MonadIO m) => Matrix -> Vec3 -> m Vec3
- matrixTransformVec4 :: (HasCallStack, MonadIO m) => Matrix -> Vec4 -> m Vec4
- matrixTranslate :: (HasCallStack, MonadIO m) => Matrix -> Point3D -> m ()
- matrixTranspose :: (HasCallStack, MonadIO m) => Matrix -> m Matrix
- matrixUnprojectPoint3d :: (HasCallStack, MonadIO m) => Matrix -> Matrix -> Point3D -> m Point3D
- matrixUntransformBounds :: (HasCallStack, MonadIO m) => Matrix -> Rect -> Rect -> m Rect
- matrixUntransformPoint :: (HasCallStack, MonadIO m) => Matrix -> Point -> Rect -> m (Bool, Point)

# Exported types

newtype Matrix Source #

Memory-managed wrapper type.

Constructors

Matrix (ManagedPtr Matrix) |

#### Instances

Instances details

Eq Matrix Source # |
Instance details Defined in GI.Graphene.Structs.Matrix Methods (==) :: Matrix -> Matrix -> Bool Source # (/=) :: Matrix -> Matrix -> Bool Source #
GBoxed Matrix Source # |
Instance details Defined in GI.Graphene.Structs.Matrix
ManagedPtrNewtype Matrix Source # |
Instance details Defined in GI.Graphene.Structs.Matrix Methods toManagedPtr :: Matrix -> ManagedPtr Matrix Source #
TypedObject Matrix Source # |
Instance details Defined in GI.Graphene.Structs.Matrix Methods glibType :: IO GType Source #
HasParentTypes Matrix Source # |
Instance details Defined in GI.Graphene.Structs.Matrix
tag ~ 'AttrSet => Constructible Matrix tag Source # |
Instance details Defined in GI.Graphene.Structs.Matrix Methods new :: MonadIO m => (ManagedPtr Matrix -> Matrix) -> [AttrOp Matrix tag] -> m Matrix Source #
IsGValue (Maybe Matrix) Source # | Convert `Matrix` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Graphene.Structs.Matrix Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Matrix -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Matrix) Source #
type ParentTypes Matrix Source # |
Instance details Defined in GI.Graphene.Structs.Matrix type ParentTypes Matrix = '[] :: [Type]

newZeroMatrix :: MonadIO m => m Matrix Source #

Construct a `Matrix` struct initialized to zero.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

decompose, determinant, equal, equalFast, free, initFrom2d, initFromFloat, initFromMatrix, initFromVec4, initFrustum, initIdentity, initLookAt, initOrtho, initPerspective, initRotate, initScale, initSkew, initTranslate, interpolate, inverse, is2d, isBackfaceVisible, isIdentity, isSingular, multiply, near, normalize, perspective, print, projectPoint, projectRect, projectRectBounds, rotate, rotateEuler, rotateQuaternion, rotateX, rotateY, rotateZ, scale, skewXy, skewXz, skewYz, to2d, transformBounds, transformBox, transformPoint, transformPoint3d, transformRay, transformRect, transformSphere, transformVec3, transformVec4, translate, transpose, unprojectPoint3d, untransformBounds, untransformPoint.

#### Getters

getRow, getValue, getXScale, getXTranslation, getYScale, getYTranslation, getZScale, getZTranslation.

#### Setters

None.

## alloc

matrixAlloc Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Matrix | Returns: the newly allocated matrix

Allocates a new `Matrix`.

Since: 1.0

## decompose

matrixDecompose Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m (Bool, Vec3, Vec3, Quaternion, Vec3, Vec4) | Returns: `true` if the matrix could be decomposed

Decomposes a transformation matrix into its component transformations.

The algorithm for decomposing a matrix is taken from the CSS3 Transforms specification; specifically, the decomposition code is based on the equivalent code published in "Graphics Gems II", edited by Jim Arvo, and available online.

## determinant

matrixDeterminant Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Float | Returns: the value of the determinant

Computes the determinant of the given matrix.

Since: 1.0

## equal

matrixEqual Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `a`: a `Matrix`
-> Matrix | `b`: a `Matrix`
-> m Bool | Returns: `true` if the two matrices are equal, and `false` otherwise

Checks whether the two given `Matrix` matrices are equal.

Since: 1.10

## equalFast

matrixEqualFast Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `a`: a `Matrix`
-> Matrix | `b`: a `Matrix`
-> m Bool | Returns: `true` if the matrices are equal. and `false` otherwise

Checks whether the two given `Matrix` matrices are byte-by-byte equal.

While this function is faster than `matrixEqual`, it can also return false negatives, so it should be used in conjuction with either `matrixEqual` or `matrixNear`. For instance:

### C code

     if (graphene_matrix_equal_fast (a, b))
       {
         // matrices are definitely the same
       }
     else
       {
         if (graphene_matrix_equal (a, b))
           // matrices contain the same values within an epsilon of FLT_EPSILON
         else if (graphene_matrix_near (a, b, 0.0001))
           // matrices contain the same values within an epsilon of 0.0001
         else
           // matrices are not equal
       }

Since: 1.10

## free

matrixFree Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m () |

Frees the resources allocated by `matrixAlloc`.

Since: 1.0

## getRow

matrixGetRow Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Word32 | `index_`: the index of the row vector, between 0 and 3
-> m Vec4 |

Retrieves the given row vector at `index_` inside a matrix.

Since: 1.0

## getValue

matrixGetValue Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Word32 | `row`: the row index
-> Word32 | `col`: the column index
-> m Float | Returns: the value at the given indices

Retrieves the value at the given `row` and `col` index.

Since: 1.0

## getXScale

matrixGetXScale Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Float | Returns: the value of the scaling factor

Retrieves the scaling factor on the X axis in `m`.

Since: 1.0

## getXTranslation

matrixGetXTranslation Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Float | Returns: the translation component

Retrieves the translation component on the X axis from `m`.

Since: 1.10

## getYScale

matrixGetYScale Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Float | Returns: the value of the scaling factor

Retrieves the scaling factor on the Y axis in `m`.

Since: 1.0

## getYTranslation

matrixGetYTranslation Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Float | Returns: the translation component

Retrieves the translation component on the Y axis from `m`.

Since: 1.10

## getZScale

matrixGetZScale Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Float | Returns: the value of the scaling factor

Retrieves the scaling factor on the Z axis in `m`.

Since: 1.0

## getZTranslation

matrixGetZTranslation Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Float | Returns: the translation component

Retrieves the translation component on the Z axis from `m`.

Since: 1.10

## initFrom2d

matrixInitFrom2d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Double | `xx`: the xx member
-> Double | `yx`: the yx member
-> Double | `xy`: the xy member
-> Double | `yy`: the yy member
-> Double | `x0`: the x0 member
-> Double | `y0`: the y0 member
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` from the values of an affine transformation matrix.

The arguments map to the following matrix layout:

### plain code

     ⎛ xx  yx ⎞   ⎛  a   b  0 ⎞
     ⎜ xy  yy ⎟ = ⎜  c   d  0 ⎟
     ⎝ x0  y0 ⎠   ⎝ tx  ty  1 ⎠

This function can be used to convert between an affine matrix type from other libraries and a `Matrix`.

Since: 1.0

## initFromFloat

matrixInitFromFloat Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> [Float] | `v`: an array of at least 16 floating point values
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with the given array of floating point values.

Since: 1.0

## initFromMatrix

matrixInitFromMatrix Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Matrix | `src`: a `Matrix`
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` using the values of the given matrix.

Since: 1.0

## initFromVec4

matrixInitFromVec4 Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Vec4 | `v0`: the first row vector
-> Vec4 | `v1`: the second row vector
-> Vec4 | `v2`: the third row vector
-> Vec4 | `v3`: the fourth row vector
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with the given four row vectors.

Since: 1.0

## initFrustum

matrixInitFrustum Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `left`: distance of the left clipping plane
-> Float | `right`: distance of the right clipping plane
-> Float | `bottom`: distance of the bottom clipping plane
-> Float | `top`: distance of the top clipping plane
-> Float | `zNear`: distance of the near clipping plane
-> Float | `zFar`: distance of the far clipping plane
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` compatible with `Frustum`.

See also: `frustumInitFromMatrix`

Since: 1.2

## initIdentity

matrixInitIdentity Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with the identity matrix.

Since: 1.0

## initLookAt

matrixInitLookAt Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Vec3 | `eye`: the vector describing the position to look from
-> Vec3 | `center`: the vector describing the position to look at
-> Vec3 | `up`: the vector describing the world's upward direction; usually, this is the `vec3YAxis` vector
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` so that it positions the "camera" at the given `eye` coordinates towards an object at the `center` coordinates. The top of the camera is aligned to the direction of the `up` vector.

Before the transform, the camera is assumed to be placed at the origin, looking towards the negative Z axis, with the top side of the camera facing in the direction of the Y axis and the right side in the direction of the X axis.

In theory, one could use `m` to transform a model of such a camera into world-space. However, it is more common to use the inverse of `m` to transform another object from world coordinates to the view coordinates of the camera. Typically you would then apply the camera projection transform to get from view to screen coordinates.

Since: 1.0

## initOrtho

matrixInitOrtho Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `left`: the left edge of the clipping plane
-> Float | `right`: the right edge of the clipping plane
-> Float | `top`: the top edge of the clipping plane
-> Float | `bottom`: the bottom edge of the clipping plane
-> Float | `zNear`: the distance of the near clipping plane
-> Float | `zFar`: the distance of the far clipping plane
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with an orthographic projection.

Since: 1.0

## initPerspective

matrixInitPerspective Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `fovy`: the field of view angle, in degrees
-> Float | `aspect`: the aspect value
-> Float | `zNear`: the near Z plane
-> Float | `zFar`: the far Z plane
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with a perspective projection.

Since: 1.0

## initRotate

matrixInitRotate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `angle`: the rotation angle, in degrees
-> Vec3 | `axis`: the axis vector as a `Vec3`
-> m Matrix | Returns: the initialized matrix

Initializes `m` to represent a rotation of `angle` degrees on the axis represented by the `axis` vector.

Since: 1.0

## initScale

matrixInitScale Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `x`: the scale factor on the X axis
-> Float | `y`: the scale factor on the Y axis
-> Float | `z`: the scale factor on the Z axis
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with the given scaling factors.

Since: 1.0

## initSkew

matrixInitSkew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `xSkew`: skew factor, in radians, on the X axis
-> Float | `ySkew`: skew factor, in radians, on the Y axis
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with a skew transformation with the given factors.

Since: 1.0

## initTranslate

matrixInitTranslate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Point3D | `p`: the translation coordinates
-> m Matrix | Returns: the initialized matrix

Initializes a `Matrix` with a translation to the given coordinates.

Since: 1.0

## interpolate

matrixInterpolate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `a`: a `Matrix`
-> Matrix | `b`: a `Matrix`
-> Double | `factor`: the linear interpolation factor
-> m Matrix |

Linearly interpolates the two given `Matrix` by interpolating the decomposed transformations separately.

If either matrix cannot be reduced to their transformations then the interpolation cannot be performed, and this function will return an identity matrix.

Since: 1.0

## inverse

matrixInverse Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m (Bool, Matrix) | Returns: `true` if the matrix is invertible

Inverts the given matrix.

Since: 1.0

## is2d

matrixIs2d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Bool | Returns: `true` if the matrix is compatible with an affine transformation matrix

Checks whether the given `Matrix` is compatible with an a 2D affine transformation matrix.

Since: 1.0

## isBackfaceVisible

matrixIsBackfaceVisible Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Bool | Returns: `true` if the back face of the matrix is visible

Checks whether a `Matrix` has a visible back face.

Since: 1.0

## isIdentity

matrixIsIdentity Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Bool | Returns: `true` if the matrix is the identity matrix

Checks whether the given `Matrix` is the identity matrix.

Since: 1.0

## isSingular

matrixIsSingular Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Bool | Returns: `true` if the matrix is singular

Checks whether a matrix is singular.

Since: 1.0

## multiply

matrixMultiply Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `a`: a `Matrix`
-> Matrix | `b`: a `Matrix`
-> m Matrix |

Multiplies two `Matrix`.

Matrix multiplication is not commutative in general; the order of the factors matters. The product of this multiplication is (`a` × `b`)

Since: 1.0

## near

matrixNear Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `a`: a `Matrix`
-> Matrix | `b`: a `Matrix`
-> Float | `epsilon`: the threshold between the two matrices
-> m Bool | Returns: `true` if the two matrices are near each other, and `false` otherwise

Compares the two given `Matrix` matrices and checks whether their values are within the given `epsilon` of each other.

Since: 1.10

## normalize

matrixNormalize Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Matrix |

Normalizes the given `Matrix`.

Since: 1.0

## perspective

matrixPerspective Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `depth`: the depth of the perspective
-> m Matrix |

Applies a perspective of `depth` to the matrix.

Since: 1.0

## print

matrixPrint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: The matrix to print
-> m () |

Prints the contents of a matrix to the standard error stream.

This function is only useful for debugging; there are no guarantees made on the format of the output.

Since: 1.0

## projectPoint

matrixProjectPoint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Point | `p`: a `Point`
-> m Point |

Projects a `Point` using the matrix `m`.

Since: 1.0

## projectRect

matrixProjectRect Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Rect | `r`: a `Rect`
-> m Quad |

Projects all corners of a `Rect` using the given matrix.

See also: `matrixProjectPoint`

Since: 1.2

## projectRectBounds

matrixProjectRectBounds Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Rect | `r`: a `Rect`
-> m Rect |

Projects a `Rect` using the given matrix.

The resulting rectangle is the axis aligned bounding rectangle capable of fully containing the projected rectangle.

Since: 1.0

## rotate

matrixRotate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `angle`: the rotation angle, in degrees
-> Vec3 | `axis`: the rotation axis, as a `Vec3`
-> m () |

Adds a rotation transformation to `m`, using the given `angle` and `axis` vector.

This is the equivalent of calling `matrixInitRotate` and then multiplying the matrix `m` with the rotation matrix.

Since: 1.0

## rotateEuler

matrixRotateEuler Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Euler | `e`: a rotation described by a `Euler`
-> m () |

Adds a rotation transformation to `m`, using the given `Euler`.

Since: 1.2

## rotateQuaternion

matrixRotateQuaternion Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Quaternion | `q`: a rotation described by a `Quaternion`
-> m () |

Adds a rotation transformation to `m`, using the given `Quaternion`.

This is the equivalent of calling `quaternionToMatrix` and then multiplying `m` with the rotation matrix.

Since: 1.2

## rotateX

matrixRotateX Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `angle`: the rotation angle, in degrees
-> m () |

Adds a rotation transformation around the X axis to `m`, using the given `angle`.

See also: `matrixRotate`

Since: 1.0

## rotateY

matrixRotateY Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `angle`: the rotation angle, in degrees
-> m () |

Adds a rotation transformation around the Y axis to `m`, using the given `angle`.

See also: `matrixRotate`

Since: 1.0

## rotateZ

matrixRotateZ Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `angle`: the rotation angle, in degrees
-> m () |

Adds a rotation transformation around the Z axis to `m`, using the given `angle`.

See also: `matrixRotate`

Since: 1.0

## scale

matrixScale Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `factorX`: scaling factor on the X axis
-> Float | `factorY`: scaling factor on the Y axis
-> Float | `factorZ`: scaling factor on the Z axis
-> m () |

Adds a scaling transformation to `m`, using the three given factors.

This is the equivalent of calling `matrixInitScale` and then multiplying the matrix `m` with the scale matrix.

Since: 1.0

## skewXy

matrixSkewXy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `factor`: skew factor
-> m () |

Adds a skew of `factor` on the X and Y axis to the given matrix.

Since: 1.0

## skewXz

matrixSkewXz Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `factor`: skew factor
-> m () |

Adds a skew of `factor` on the X and Z axis to the given matrix.

Since: 1.0

## skewYz

matrixSkewYz Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Float | `factor`: skew factor
-> m () |

Adds a skew of `factor` on the Y and Z axis to the given matrix.

Since: 1.0

## to2d

matrixTo2d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m (Bool, Double, Double, Double, Double, Double, Double) | Returns: `true` if the matrix is compatible with an affine transformation matrix

Converts a `Matrix` to an affine transformation matrix, if the given matrix is compatible.

The returned values have the following layout:

### plain code

     ⎛ xx  yx ⎞   ⎛  a   b  0 ⎞
     ⎜ xy  yy ⎟ = ⎜  c   d  0 ⎟
     ⎝ x0  y0 ⎠   ⎝ tx  ty  1 ⎠

This function can be used to convert between a `Matrix` and an affine matrix type from other libraries.

Since: 1.0

## transformBounds

matrixTransformBounds Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Rect | `r`: a `Rect`
-> m Rect |

Transforms each corner of a `Rect` using the given matrix `m`.

The result is the axis aligned bounding rectangle containing the coplanar quadrilateral.

See also: `matrixTransformPoint`

Since: 1.0

## transformBox

matrixTransformBox Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Box | `b`: a `Box`
-> m Box |

Transforms the vertices of a `Box` using the given matrix `m`.

The result is the axis aligned bounding box containing the transformed vertices.

Since: 1.2

## transformPoint

matrixTransformPoint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Point | `p`: a `Point`
-> m Point |

Transforms the given `Point` using the matrix `m`.

Unlike `matrixTransformVec3`, this function will take into account the fourth row vector of the `Matrix` when computing the dot product of each row vector of the matrix.

See also: `graphene_simd4x4f_point3_mul()`

Since: 1.0

## transformPoint3d

matrixTransformPoint3d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Point3D | `p`: a `Point3D`
-> m Point3D |

Transforms the given `Point3D` using the matrix `m`.

Unlike `matrixTransformVec3`, this function will take into account the fourth row vector of the `Matrix` when computing the dot product of each row vector of the matrix.

See also: `graphene_simd4x4f_point3_mul()`

Since: 1.2

## transformRay

matrixTransformRay Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Ray | `r`: a `Ray`
-> m Ray |

Transform a `Ray` using the given matrix `m`.

Since: 1.4

## transformRect

matrixTransformRect Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Rect | `r`: a `Rect`
-> m Quad |

Transforms each corner of a `Rect` using the given matrix `m`.

The result is a coplanar quadrilateral.

See also: `matrixTransformPoint`

Since: 1.0

## transformSphere

matrixTransformSphere Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Sphere | `s`: a `Sphere`
-> m Sphere |

Transforms a `Sphere` using the given matrix `m`. The result is the bounding sphere containing the transformed sphere.

Since: 1.2

## transformVec3

matrixTransformVec3 Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Vec3 | `v`: a `Vec3`
-> m Vec3 |

Transforms the given `Vec3` using the matrix `m`.

This function will multiply the X, Y, and Z row vectors of the matrix `m` with the corresponding components of the vector `v`. The W row vector will be ignored.

See also: `graphene_simd4x4f_vec3_mul()`

Since: 1.0

## transformVec4

matrixTransformVec4 Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Vec4 | `v`: a `Vec4`
-> m Vec4 |

Transforms the given `Vec4` using the matrix `m`.

See also: `graphene_simd4x4f_vec4_mul()`

Since: 1.0

## translate

matrixTranslate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Point3D | `pos`: a `Point3D`
-> m () |

Adds a translation transformation to `m` using the coordinates of the given `Point3D`.

This is the equivalent of calling `matrixInitTranslate` and then multiplying `m` with the translation matrix.

Since: 1.0

## transpose

matrixTranspose Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> m Matrix |

Transposes the given matrix.

Since: 1.0

## unprojectPoint3d

matrixUnprojectPoint3d Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `projection`: a `Matrix` for the projection matrix
-> Matrix | `modelview`: a `Matrix` for the modelview matrix; this is the inverse of the modelview used when projecting the point
-> Point3D | `point`: a `Point3D` with the coordinates of the point
-> m Point3D |

Unprojects the given `point` using the `projection` matrix and a `modelview` matrix.

Since: 1.2

## untransformBounds

matrixUntransformBounds Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Rect | `r`: a `Rect`
-> Rect | `bounds`: the bounds of the transformation
-> m Rect |

Undoes the transformation on the corners of a `Rect` using the given matrix, within the given axis aligned rectangular `bounds`.

Since: 1.0

## untransformPoint

matrixUntransformPoint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Matrix | `m`: a `Matrix`
-> Point | `p`: a `Point`
-> Rect | `bounds`: the bounds of the transformation
-> m (Bool, Point) | Returns: `true` if the point was successfully untransformed

Undoes the transformation of a `Point` using the given matrix, within the given axis aligned rectangular `bounds`.

Since: 1.0