Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mat4

Mathematical 4x4 matrix.

Hierarchy

Index

Constructors

constructor

  • newMat4(other: Mat4): Mat4
  • newMat4(m00?: undefined | number, m01?: undefined | number, m02?: undefined | number, m03?: undefined | number, m04?: undefined | number, m05?: undefined | number, m06?: undefined | number, m07?: undefined | number, m08?: undefined | number, m09?: undefined | number, m10?: undefined | number, m11?: undefined | number, m12?: undefined | number, m13?: undefined | number, m14?: undefined | number, m15?: undefined | number): Mat4
  • Parameters

    Returns Mat4

  • Parameters

    • Optional m00: undefined | number
    • Optional m01: undefined | number
    • Optional m02: undefined | number
    • Optional m03: undefined | number
    • Optional m04: undefined | number
    • Optional m05: undefined | number
    • Optional m06: undefined | number
    • Optional m07: undefined | number
    • Optional m08: undefined | number
    • Optional m09: undefined | number
    • Optional m10: undefined | number
    • Optional m11: undefined | number
    • Optional m12: undefined | number
    • Optional m13: undefined | number
    • Optional m14: undefined | number
    • Optional m15: undefined | number

    Returns Mat4

Properties

m00

m00: number

Value at column 0 row 0 of the matrix.

m01

m01: number

Value at column 0 row 1 of the matrix.

m02

m02: number

Value at column 0 row 2 of the matrix.

m03

m03: number

Value at column 0 row 3 of the matrix.

m04

m04: number

Value at column 1 row 0 of the matrix.

m05

m05: number

Value at column 1 row 1 of the matrix.

m06

m06: number

Value at column 1 row 2 of the matrix.

m07

m07: number

Value at column 1 row 3 of the matrix.

m08

m08: number

Value at column 2 row 0 of the matrix.

m09

m09: number

Value at column 2 row 1 of the matrix.

m10

m10: number

Value at column 2 row 2 of the matrix.

m11

m11: number

Value at column 2 row 3 of the matrix.

m12

m12: number

Value at column 3 row 0 of the matrix.

m13

m13: number

Value at column 3 row 1 of the matrix.

m14

m14: number

Value at column 3 row 2 of the matrix.

m15

m15: number

Value at column 3 row 3 of the matrix.

Static IDENTITY

IDENTITY: Readonly<Mat4> = Object.freeze(new Mat4())

Methods

add

  • add(mat: Mat4): this
  • Adds the current matrix and another matrix to the current matrix.

    Parameters

    • mat: Mat4

      the second operand

    Returns this

clone

determinant

  • determinant(): number

equals

  • equals(other: Mat4, epsilon?: number): boolean
  • Returns whether the specified matrices are approximately equal.

    Parameters

    • other: Mat4

      Comparative matrix

    • Default value epsilon: number = EPSILON

      The error allowed. It`s should be a non-negative number.

    Returns boolean

    Returns true' when the elements of both matrices are equal; otherwise returns false'.

fromQuat

  • fromQuat(q: Quat): this

fromRTS

  • Resets the matrix values by the given rotation quaternion, translation vector and scale vector

    Parameters

    • q: Quat

      Rotation quaternion

    • v: Vec3

      Translation vector

    • s: Vec3

      Scaling vector

    Returns this

    this

getRotation

getScale

getTranslation

  • Returns the translation vector component of a transformation matrix.

    Parameters

    • out: Vec3

      Vector to receive translation component.

    Returns Vec3

identity

  • identity(): this

invert

  • invert(): this
  • Inverts the current matrix. When matrix is not invertible the matrix will be set to zeros.

    Returns this

multiply

  • multiply(mat: Mat4): this

multiplyScalar

  • multiplyScalar(scalar: number): this
  • Multiply each element of the current matrix by a scalar number.

    Parameters

    • scalar: number

      amount to scale the matrix's elements by

    Returns this

rotate

  • rotate(rad: number, axis: Vec3): null | this
  • Rotates the current matrix by the given angle around the given axis

    Parameters

    • rad: number

      Angle of rotation (in radians)

    • axis: Vec3

      Axis of rotation

    Returns null | this

scale

  • scale(vec: Vec3): this

set

  • set(other: Mat4): any
  • set(m00?: undefined | number, m01?: undefined | number, m02?: undefined | number, m03?: undefined | number, m04?: undefined | number, m05?: undefined | number, m06?: undefined | number, m07?: undefined | number, m08?: undefined | number, m09?: undefined | number, m10?: undefined | number, m11?: undefined | number, m12?: undefined | number, m13?: undefined | number, m14?: undefined | number, m15?: undefined | number): any
  • Sets the matrix with another one's value.

    Parameters

    • other: Mat4

      Specified matrix.

    Returns any

    this

  • Set the matrix with values of all elements

    Parameters

    • Optional m00: undefined | number
    • Optional m01: undefined | number
    • Optional m02: undefined | number
    • Optional m03: undefined | number
    • Optional m04: undefined | number
    • Optional m05: undefined | number
    • Optional m06: undefined | number
    • Optional m07: undefined | number
    • Optional m08: undefined | number
    • Optional m09: undefined | number
    • Optional m10: undefined | number
    • Optional m11: undefined | number
    • Optional m12: undefined | number
    • Optional m13: undefined | number
    • Optional m14: undefined | number
    • Optional m15: undefined | number

    Returns any

    this

strictEquals

  • strictEquals(other: Mat4): boolean
  • Returns whether the specified matrices are equal.

    Parameters

    • other: Mat4

      Comparative matrix

    Returns boolean

    Returns true' when the elements of both matrices are equal; otherwise returns false'.

subtract

  • subtract(mat: Mat4): this

toString

  • toString(): string

translate

  • translate(vec: Vec3): this

transpose

  • transpose(): this

zero

  • zero(): this

Static add

  • add<Out>(out: Out, a: Out, b: Out): Out

Static clone

  • clone<Out>(a: Out): Mat4

Static copy

  • copy<Out>(out: Out, a: Out): Out

Static determinant

  • determinant<Out>(a: Out): number

Static equals

  • equals<Out>(a: Out, b: Out, epsilon?: number): boolean
  • Returns whether the specified matrices are approximately equal.

    Type parameters

    Parameters

    • a: Out
    • b: Out
    • Default value epsilon: number = EPSILON

    Returns boolean

Static fromArray

  • fromArray<Out>(out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out
  • Generates or sets a matrix with a flat array

    Type parameters

    Parameters

    • out: Out
    • arr: IWritableArrayLike<number>
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static fromQuat

  • fromQuat<Out>(out: Out, q: Quat): Out

Static fromRT

  • fromRT<Out, VecLike>(out: Out, q: Quat, v: VecLike): Out

Static fromRTS

  • fromRTS<Out, VecLike>(out: Out, q: Quat, v: VecLike, s: VecLike): Out

Static fromRTSOrigin

  • fromRTSOrigin<Out, VecLike>(out: Out, q: Quat, v: VecLike, s: VecLike, o: VecLike): Out
  • Compose a matrix from scale, rotation and translation, applied in order, from a given origin

    Type parameters

    Parameters

    • out: Out
    • q: Quat

      Rotation quaternion

    • v: VecLike

      Translation vector

    • s: VecLike

      Scaling vector

    • o: VecLike

      transformation Center

    Returns Out

Static fromRotation

  • fromRotation<Out, VecLike>(out: Out, rad: number, axis: VecLike): null | Out

Static fromScaling

  • fromScaling<Out, VecLike>(out: Out, v: VecLike): Out

Static fromTranslation

  • fromTranslation<Out, VecLike>(out: Out, v: VecLike): Out

Static fromXRotation

  • fromXRotation<Out>(out: Out, rad: number): Out

Static fromYRotation

  • fromYRotation<Out>(out: Out, rad: number): Out

Static fromZRotation

  • fromZRotation<Out>(out: Out, rad: number): Out

Static frustum

  • frustum<Out>(out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number): Out
  • Calculates the matrix representing the given frustum

    Type parameters

    Parameters

    • out: Out
    • left: number

      The X coordinate of the left side of the near projection plane in view space.

    • right: number

      The X coordinate of the right side of the near projection plane in view space.

    • bottom: number

      The Y coordinate of the bottom side of the near projection plane in view space.

    • top: number

      The Y coordinate of the top side of the near projection plane in view space.

    • near: number

      Z distance to the near plane from the origin in view space.

    • far: number

      Z distance to the far plane from the origin in view space.

    Returns Out

Static getRotation

  • getRotation<Out>(out: Quat, mat: Out): Quat

Static getScaling

  • getScaling<Out, VecLike>(out: VecLike, mat: Out): VecLike
  • Extracts the scale vector from the matrix, assuming it's composed in order of scale, rotation, translation

    Type parameters

    Parameters

    • out: VecLike
    • mat: Out

    Returns VecLike

Static getTranslation

  • getTranslation<Out, VecLike>(out: VecLike, mat: Out): VecLike
  • Extracts the translation from the matrix, assuming it's composed in order of scale, rotation, translation

    Type parameters

    Parameters

    • out: VecLike
    • mat: Out

    Returns VecLike

Static identity

  • identity<Out>(out: Out): Out

Static inverseTranspose

  • inverseTranspose<Out>(out: Out, a: Out): null | Out
  • Calculates the inverse transpose of a matrix and save the results to out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out

    Returns null | Out

Static invert

  • invert<Out>(out: Out, a: Out): Out
  • Inverts a matrix. When matrix is not invertible the matrix will be set to zeros.

    Type parameters

    Parameters

    • out: Out
    • a: Out

    Returns Out

Static lookAt

  • lookAt<Out, VecLike>(out: Out, eye: VecLike, center: VecLike, up: VecLike): Out
  • Calculates the matrix with the view point information, given by eye position, target center and the up vector. Note that center to eye vector can't be zero or parallel to the up vector

    Type parameters

    Parameters

    • out: Out
    • eye: VecLike

      The source point.

    • center: VecLike

      The target point.

    • up: VecLike

      The vector describing the up direction.

    Returns Out

Static multiply

  • multiply<Out>(out: Out, a: Out, b: Out): Out

Static multiplyScalar

  • multiplyScalar<Out>(out: Out, a: Out, b: number): Out
  • Multiply each element of a matrix by a scalar number and save the results to out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: number

    Returns Out

Static multiplyScalarAndAdd

  • multiplyScalarAndAdd<Out>(out: Out, a: Out, b: Out, scale: number): Out
  • Adds two matrices after multiplying each element of the second operand by a scalar number. And save the results to out matrix.

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: Out
    • scale: number

    Returns Out

Static ortho

  • ortho<Out>(out: Out, left: number, right: number, bottom: number, top: number, near: number, far: number, minClipZ?: number, projectionSignY?: number, orientation?: number): Out
  • Calculates orthogonal projection matrix

    Type parameters

    Parameters

    • out: Out
    • left: number

      Left-side x-coordinate.

    • right: number

      Right-side x-coordinate.

    • bottom: number

      Bottom y-coordinate.

    • top: number

      Top y-coordinate.

    • near: number

      Near depth clipping plane value.

    • far: number

      Far depth clipping plane value.

    • Default value minClipZ: number = -1
    • Default value projectionSignY: number = 1
    • Default value orientation: number = 0

    Returns Out

Static perspective

  • perspective<Out>(out: Out, fov: number, aspect: number, near: number, far: number, isFOVY?: boolean, minClipZ?: number, projectionSignY?: number, orientation?: number): Out
  • Calculates perspective projection matrix

    Type parameters

    Parameters

    • out: Out
    • fov: number
    • aspect: number

      Aspect ratio

    • near: number

      Near depth clipping plane value.

    • far: number

      Far depth clipping plane value.

    • Default value isFOVY: boolean = true
    • Default value minClipZ: number = -1
    • Default value projectionSignY: number = 1
    • Default value orientation: number = 0

    Returns Out

Static rotate

  • rotate<Out, VecLike>(out: Out, a: Out, rad: number, axis: VecLike): null | Out
  • Rotates the transform by the given angle and save the results into the out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • rad: number

      Angle of rotation (in radians)

    • axis: VecLike

      axis of rotation

    Returns null | Out

Static rotateX

  • rotateX<Out>(out: Out, a: Out, rad: number): Out
  • Transform a matrix with a given angle around X axis and save the results to the out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • rad: number

      Angle of rotation (in radians)

    Returns Out

Static rotateY

  • rotateY<Out>(out: Out, a: Out, rad: number): Out
  • Transform a matrix with a given angle around Y axis and save the results to the out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • rad: number

      Angle of rotation (in radians)

    Returns Out

Static rotateZ

  • rotateZ<Out>(out: Out, a: Out, rad: number): Out
  • Transform a matrix with a given angle around Z axis and save the results to the out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • rad: number

      Angle of rotation (in radians)

    Returns Out

Static scale

  • scale<Out, VecLike>(out: Out, a: Out, v: VecLike): Out
  • Multiply a matrix with a scale matrix given by a scale vector and save the results into the out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • v: VecLike

    Returns Out

Static set

  • set<Out>(out: Out, m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): Out
  • Sets a matrix with the given values and save the results to out matrix

    Type parameters

    Parameters

    • out: Out
    • m00: number
    • m01: number
    • m02: number
    • m03: number
    • m10: number
    • m11: number
    • m12: number
    • m13: number
    • m20: number
    • m21: number
    • m22: number
    • m23: number
    • m30: number
    • m31: number
    • m32: number
    • m33: number

    Returns Out

Static strictEquals

  • strictEquals<Out>(a: Out, b: Out): boolean

Static subtract

  • subtract<Out>(out: Out, a: Out, b: Out): Out
  • Subtracts matrix b from matrix a and save the results to out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • b: Out

    Returns Out

Static toArray

  • toArray<Out>(out: Out, m: IMat4Like, ofs?: number): Out
  • Transform a matrix object to a flat array

    Type parameters

    • Out: IWritableArrayLike<number>

    Parameters

    • out: Out
    • m: IMat4Like
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static toRTS

  • toRTS<Out, VecLike>(m: Out, q: Quat, v: VecLike, s: VecLike): void
  • Extracts the scale, rotation and translation from the matrix, assuming it's composed in order of scale, rotation, translation

    Type parameters

    Parameters

    • m: Out
    • q: Quat
    • v: VecLike
    • s: VecLike

    Returns void

Static transform

  • transform<Out, VecLike>(out: Out, a: Out, v: VecLike): Out

Static translate

  • translate<Out, VecLike>(out: Out, a: Out, v: VecLike): Out
  • Transform a matrix with the given translation vector and save results to the out matrix

    Type parameters

    Parameters

    • out: Out
    • a: Out
    • v: VecLike

    Returns Out

Static transpose

  • transpose<Out>(out: Out, a: Out): Out

Generated using TypeDoc