Skip to main content

Matrix

Excalibur Matrix helper for 4x4 matrices

Useful for webgl 4x4 matrices

Index

Constructors

constructor

Properties

publicdata

data: Float32Array = ...

4x4 matrix in column major order

data[0]data[4]data[8]data[12]
data[1]data[5]data[9]data[13]
data[2]data[6]data[10]data[14]
data[3]data[7]data[11]data[15]

Methods

publicclone

  • Creates a new Matrix with the same data as the current 4x4


    Parameters

    Returns Matrix

publicgetAffineInverse

  • Return the affine inverse, optionally store it in a target matrix.

    It's recommended you call .reset() the target unless you know what you're doing


    Parameters

    Returns Matrix

publicgetBasisDeterminant

  • getBasisDeterminant(): number
  • Determinant of the upper left 2x2 matrix


    Returns number

publicgetPosition

publicgetRotation

  • getRotation(): number
  • Returns number

publicgetScale

  • Get the scale of the matrix


    Returns Vector

publicgetScaleX

  • getScaleX(): number
  • Returns number

publicgetScaleY

  • getScaleY(): number
  • Returns number

publicisIdentity

  • isIdentity(): boolean
  • Returns boolean

multiply

  • Multiply the current matrix by a vector producing a new vector


    Parameters

    Returns Vector

publicreset

  • Resets the current matrix to the identity matrix, mutating it


    Returns Matrix

    Current matrix as identity

rotate

  • Applies rotation to the current matrix mutating it


    Parameters

    • angle: number

      in Radians

    Returns Matrix

scale

  • scale(x: number, y: number): Matrix
  • Applies scaling to the current matrix mutating it


    Parameters

    • x: number
    • y: number

    Returns Matrix

publicsetPosition

  • setPosition(x: number, y: number): void
  • Parameters

    • x: number
    • y: number

    Returns void

publicsetRotation

  • setRotation(angle: number): void
  • Parameters

    • angle: number

    Returns void

publicsetScale

  • Parameters

    Returns void

publicsetScaleX

  • setScaleX(val: number): void
  • Parameters

    • val: number

    Returns void

publicsetScaleY

  • setScaleY(val: number): void
  • Parameters

    • val: number

    Returns void

publictoDOMMatrix

  • toDOMMatrix(): DOMMatrix
  • Converts the current matrix into a DOMMatrix

    This is useful when working with the browser Canvas context


    Returns DOMMatrix

    DOMMatrix

publictoString

  • toString(): string
  • Returns string

translate

  • translate(x: number, y: number): Matrix
  • Applies translation to the current matrix mutating it


    Parameters

    • x: number
    • y: number

    Returns Matrix

publicstaticfromFloat32Array

  • fromFloat32Array(data: Float32Array): Matrix
  • Parameters

    • data: Float32Array

    Returns Matrix

publicstaticidentity

  • Creates a new identity matrix (a matrix that when applied does nothing)


    Returns Matrix

publicstaticortho

  • ortho(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix

publicstaticrotation

  • rotation(angle: number): Matrix
  • Creates a brand new rotation matrix with the specified angle in radians


    Parameters

    • angle: number

    Returns Matrix

publicstaticscale

  • scale(sx: number, sy: number): Matrix
  • Creates a brand new scaling matrix with the specified scaling factor


    Parameters

    • sx: number
    • sy: number

    Returns Matrix

publicstatictranslation

  • translation(x: number, y: number): Matrix
  • Creates a brand new translation matrix at the specified 3d point


    Parameters

    • x: number
    • y: number

    Returns Matrix