Docs for Version: 1.0a
Show:
Module: Math

Matrix class

Constructor

Matrix

()

Methods

frustum

(
  • l
  • r
  • b
  • t
  • n
  • f
)
Matrix

Sets up a viewing frustum, which is shaped like a truncated pyramid with the camera where the point of the pyramid would be. This emulates the OpenGL

Parameters:

  • l Float

    Left

  • r Float

    Right

  • b Float

    Bottom

  • t Float

    Top

  • n Float

    Near

  • f Float

    Far

Returns:

Matrix:

Result matrix

inverse

() Matrix

Returns the matrix that when multiplied with this matrix results in the identity matrix.

Returns:

Matrix:

Inverted matrix

lookAt

(
  • e
  • c
  • u
)
Matrix

Create a matrix that puts the camera at the eye point ex, ey, ez looking toward the center point cx, cy, cz with an up direction of ux, uy, uz.

Parameters:

Returns:

Matrix:

Result matrix

multiply

(
  • matrix
)
Matrix

Concatenates the transforms for this matrix and matrix.

Parameters:

  • matrix Matrix

    Matrix to multiply

Returns:

Matrix:

Multiplied matrix

ortho

(
  • l
  • r
  • b
  • t
  • n
  • f
)
Matrix

Creates an orthographic projection, in which objects are the same size no matter how far away or nearby they are.

Parameters:

  • l Float

    Left

  • r Float

    Right

  • b Float

    Bottom

  • t Float

    Top

  • n Float

    Near

  • f Float

    Far

Returns:

Matrix:

Result matrix

orthoPerspective

(
  • fov
  • aspect
  • near
  • far
)
Matrix

Sets up an ortho perspective transform. The aspect argument is the width divided by the height of your viewport and fov is the top-to-bottom angle of the field of view in degrees.

Parameters:

  • fov Float

    Field of View

  • aspect Float

    Aspect ratio

  • near Float

    Near plane

  • far Float

    Far plane

Returns:

Matrix:

Result matrix

perspective

(
  • fov
  • aspect
  • near
  • far
)
Matrix

Sets up a perspective transform, which makes far away objects appear smaller than nearby objects. The aspect argument is the width divided by the height of your viewport and fov is the top-to-bottom angle of the field of view in degrees.

Parameters:

  • fov Float

    Field of View

  • aspect Float

    Aspect ratio

  • near Float

    Near plane

  • far Float

    Far plane

Returns:

Matrix:

Result matrix

rotate

(
  • a
  • x
  • y
  • z
)
Matrix

Creates a matrix that rotates by a degrees around the vector x, y, z.

Parameters:

  • a Float

    Angle in degrees

  • x Float

    Vector X value

  • y Float

    Vector Y value

  • z Float

    Vector Z value

Returns:

Matrix:

Result matrix

rotate

(
  • xAngle
  • yAngle
  • zAngle
)
Matrix

Creates a matrix that rotates in three axes x, y, z.

Parameters:

  • xAngle Float

    in degrees

  • yAngle Float

    in degrees

  • zAngle Float

    in degrees

Returns:

Matrix:

Result matrix

scale

(
  • x
  • y
  • z
)
Matrix

Creates a matrix that scales by the vector x, y, z.

Parameters:

  • x Float

    Vector X value

  • y Float

    Vector Y value

  • z Float

    Vector Z value

Returns:

Matrix:

Result matrix

toInverseMat3

() Matrix3

Returns the matrix that when multiplied with this matrix results in the identity matrix3.

Returns:

Matrix3:

Inverted matrix3

transformPoint

() Vector

Transforms the vector as a point with a w coordinate of 1. This means translations will have an effect, for example.

Returns:

Vector:

Transformed Vector

transformVector

() Vector

Transforms the vector as a vector with a w coordinate of 0. This means translations will have no effect, for example.

Returns:

Vector:

Transformed Vector

translate

(
  • x
  • y
  • z
)
Matrix

Creates a matrix that translates by the vector x, y, z.

Parameters:

  • x Float

    Vector X value

  • y Float

    Vector Y value

  • z Float

    Vector Z value

Returns:

Matrix:

Result matrix

transpose

() Matrix

Exchanges columns for rows.

Returns:

Matrix:

Transposed matrix