Options
All
  • Public
  • Public/Protected
  • All
Menu

@thi.ng/matrices

Index

Interfaces

Type aliases

Variables

Functions

Type aliases

IMatrix

IMatrix<T>: IVector<T>

Type parameters

  • T

Mat

Mat: Vec

Mat22Like

Mat22Like: Tuple<number, 4> | TypedArray

Mat23Like

Mat23Like: Tuple<number, 6> | TypedArray

Mat33Like

Mat33Like: Tuple<number, 9> | TypedArray

Mat44Like

Mat44Like: Tuple<number, 16> | TypedArray

MatOp1

MatOp1: (out: Mat | null) => Mat

Type declaration

MatOpM

MatOpM: (out: Mat | null, a: ReadonlyMat) => Mat

Type declaration

MatOpMM

MatOpMM: (out: Mat | null, a: ReadonlyMat, b: ReadonlyMat) => Mat

Type declaration

MatOpMN

MatOpMN: (out: Mat | null, a: ReadonlyMat, n: number) => Mat

Type declaration

MatOpMU

MatOpMU: (out: Mat | null, a: ReadonlyMat) => Mat | undefined

Type declaration

MatOpMV

MatOpMV: (out: Vec | null, a: ReadonlyMat, b: ReadonlyVec) => Vec

Type declaration

    • Parameters

      Returns Vec

MatOpN

MatOpN: (out: Mat | null, n: number) => Mat

Type declaration

    • (out: Mat | null, n: number): Mat
    • Parameters

      • out: Mat | null
      • n: number

      Returns Mat

MatOpNV

MatOpNV: (out: Mat | null, n: number | ReadonlyVec) => Mat

Type declaration

    • (out: Mat | null, n: number | ReadonlyVec): Mat
    • Parameters

      • out: Mat | null
      • n: number | ReadonlyVec

      Returns Mat

MatOpV

MatOpV: (out: Mat | null, a: ReadonlyVec) => Mat

Type declaration

    • (out: Mat | null, a: ReadonlyVec): Mat
    • Parameters

      • out: Mat | null
      • a: ReadonlyVec

      Returns Mat

MultiMatOp

MultiMatOp<T>: MultiVecOp<T>

Type parameters

  • T

ReadonlyMat

ReadonlyMat: ReadonlyVec

VecOpM

VecOpM: (out: Vec | null, a: ReadonlyMat) => Vec

Type declaration

VecOpMN

VecOpMN: (out: Vec | null, a: ReadonlyMat, n: number) => Vec

Type declaration

Variables

IDENT22

IDENT22: ReadonlyMat = ...

IDENT23

IDENT23: ReadonlyMat = ...

IDENT33

IDENT33: ReadonlyMat = ...

IDENT44

IDENT44: ReadonlyMat = ...

add

add: MultiMatOpMM = ...

Componentwise matrix addition. If out is not given, writes result in a. Both input matrices MUST be of same size.

out = a + b

param out
param a
param b

addN

addN: MultiMatOpMN = ...

Adds single scalar componentwise to matrix. If out is not given, writes result in mat.

out = mat + n

param out
param mat
param n

column

column: MultiVecOpMN = ...

Extracts column vector from given matrix and writes result to out. If out is null, creates new vector.

param out
param mat
param column

diag

diag: MultiVecOpM = ...

Extracts matrix diagonal into out.

param out
param mat

div

div: MultiMatOpMM = ...

Componentwise matrix division. If out is not given, writes result in a. Both input matrices MUST be of same size.

out = a / b

param out
param a
param b

divN

divN: MultiMatOpMN = ...

Componentwise matrix division by single scalar. If out is not given, writes result in mat.

out = mat / n

param out
param mat
param n

identity

identity: MultiMatOp1 = ...

Writes identity matrix into given matrix.

invert

invert: MultiMatOpMU = ...

Matrix inversion. Returns undefined if matrix is not invertible. Mutates mat if out is null.

param out
param mat

mul

mul: MultiMatOpMM = ...

Componentwise matrix multiplication. Use mulM or concat for actual matrix-matrix multiplication/concatenation. If out is not given, writes result in a. Both input matrices MUST be of same size.

out = a * b

param out
param a
param b

mulM

mulM: MultiMatOpMM = ...

Multi-method. Performs matrix-matrix multiplication. If out is not given, writes result in a.

param out
param a
param b

mulN

mulN: MultiMatOpMN = ...

Multiplies matrix componentwise with single scalar. If out is not given, writes result in mat.

out = mat * n

param out
param mat
param n

mulV

mulV: MultiMatOpMV = ...

Matrix-vector multiplication. Supports in-place modification, i.e. if out === v.

param out
param m
param v

outerProduct

outerProduct: MultiVecOpVV = ...

Computes outer/tensor product of vectors u and v. Returns square matrix of same dimensions as vectors, e.g. 3x3 matrix for 3D vectors.

row

row: MultiVecOpMN = ...

Extracts row vector from given matrix and writes result to out. If out is null, creates new vector.

param out
param mat
param column

sub

sub: MultiMatOpMM = ...

Componentwise matrix subtraction. If out is not given, writes result in a. Both input matrices MUST be of same size.

out = a - b

param out
param a
param b

subN

subN: MultiMatOpMN = ...

Componentwise scalar subtraction. If out is not given, writes result in mat.

out = mat - n

param out
param mat
param n

Functions

Const add22

  • add22(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

add23

  • add23(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

add33

  • add33(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

add44

  • add44(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

Const addN22

  • addN22(out: null | Vec, a: ReadonlyVec, n: number): Vec

addN23

  • addN23(out: null | Vec, a: ReadonlyVec, n: number): Vec

addN33

  • addN33(out: null | Vec, a: ReadonlyVec, n: number): Vec

addN44

  • addN44(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const alignmentQuat

  • alignmentQuat(from: ReadonlyVec, to: ReadonlyVec, normalize?: boolean): Vec
  • Returns quaternion describing the rotation from direction vector from -> to. If normalize is true (default), first normalizes the vectors (not modifying original).

    Parameters

    • from: ReadonlyVec
    • to: ReadonlyVec
    • normalize: boolean = true

    Returns Vec

Const column22

  • column22(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const column23

  • column23(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const column33

  • column33(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const column44

  • column44(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const concat

  • concat(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec, ...xs: ReadonlyVec[]): Vec
  • Concatenates / multiplies given matrices in left-to-right order. A minimum of 2 input matrices must be given. If out is null, writes result into a.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec
    • Rest ...xs: ReadonlyVec[]

    Returns Vec

Const conjugateQ

  • conjugateQ(out: null | Vec, a: ReadonlyVec): Vec

Const defMath

Const defMathN

Const det22

  • det22(m: ReadonlyVec): number

Const det23

  • det23(m: ReadonlyVec): number

Const det33

  • det33(m: ReadonlyVec): number

Const det44

  • det44(m: ReadonlyVec): number

Const det44FromCoeffs

  • det44FromCoeffs(d: number[]): number

Const detCoeffs44

  • detCoeffs44(m: ReadonlyVec): number[]

Const diag22

  • diag22(out: null | Vec, a: ReadonlyVec): Vec

Const diag23

  • diag23(out: null | Vec, a: ReadonlyVec): Vec

Const diag33

  • diag33(out: null | Vec, a: ReadonlyVec): Vec

Const diag44

  • diag44(out: null | Vec, a: ReadonlyVec): Vec

Const div22

  • div22(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

div23

  • div23(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

div33

  • div33(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

div44

  • div44(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

Const divN22

  • divN22(out: null | Vec, a: ReadonlyVec, n: number): Vec

divN23

  • divN23(out: null | Vec, a: ReadonlyVec, n: number): Vec

divN33

  • divN33(out: null | Vec, a: ReadonlyVec, n: number): Vec

divN44

  • divN44(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const frustum

  • frustum(out: null | Vec, left: number, right: number, bottom: number, top: number, near: number, far: number): Vec
  • Constructs a 4x4 matrix representing the given view frustum. Creates new matrix if out is null.

    Parameters

    • out: null | Vec
    • left: number
    • right: number
    • bottom: number
    • top: number
    • near: number
    • far: number

    Returns Vec

Const frustumBounds

  • frustumBounds(fovy: number, aspect: number, near: number, far: number): { bottom: number; far: number; left: number; near: number; right: number; top: number }
  • Parameters

    • fovy: number
    • aspect: number
    • near: number
    • far: number

    Returns { bottom: number; far: number; left: number; near: number; right: number; top: number }

    • bottom: number
    • far: number
    • left: number
    • near: number
    • right: number
    • top: number

Const identity22

  • identity22(out: null | Vec): Vec

Const identity23

  • identity23(out: null | Vec): Vec

Const identity33

  • identity33(out: null | Vec): Vec

Const identity44

  • identity44(out: null | Vec): Vec

Const invert22

  • invert22(out: null | Vec, a: ReadonlyVec): undefined | Vec

Const invert23

  • invert23(out: null | Vec, a: ReadonlyVec): undefined | Vec

Const invert33

  • invert33(out: null | Vec, a: ReadonlyVec): undefined | Vec

Const invert44

  • invert44(out: null | Vec, a: ReadonlyVec): undefined | Vec

Const invertQ

  • invertQ(out: null | Vec, a: ReadonlyVec): Vec

Const isOrthagonal

  • isOrthagonal(m: ReadonlyVec, n: number, eps?: number): boolean

Const lookAt

  • lookAt(out: null | Vec, eye: ReadonlyVec, target: ReadonlyVec, up: ReadonlyVec): Vec
  • Constructs a 4x4 camera matrix for given eye position, look-at target (both in world space) and normalized up vector. Creates new matrix if out is null.

    Parameters

    • out: null | Vec
    • eye: ReadonlyVec
    • target: ReadonlyVec
    • up: ReadonlyVec

    Returns Vec

Const mat22n

  • mat22n(out: null | Vec, n: number): Vec

Const mat22to23

  • mat22to23(out: null | Vec, a: ReadonlyVec): Vec
  • Converts 2x2 to 2x3 matrix and writes result to out. Creates new matrix if out is null.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const mat22v

  • mat22v(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec): Vec
  • Initializes 2x2 matrix from 2D column vectors.

    Parameters

    • a: null | Vec
    • b: ReadonlyVec
    • c: ReadonlyVec

    Returns Vec

Const mat23n

  • mat23n(out: null | Vec, n: number): Vec

Const mat23to22

  • mat23to22(out: null | Vec, a: ReadonlyVec): Vec
  • Converts 2x3 to 2x2 matrix and writes result to out. Creates new matrix if out is null.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const mat23to44

  • mat23to44(out: null | Vec, a: ReadonlyVec): Vec
  • Converts 2x3 to 4x4 matrix and writes result to out. Creates new matrix if out is null.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const mat23v

  • mat23v(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec, d: ReadonlyVec): Vec
  • Initializes 2x3 matrix (affine transform) from 2D column vectors.

    Parameters

    • a: null | Vec
    • b: ReadonlyVec
    • c: ReadonlyVec
    • d: ReadonlyVec

    Returns Vec

Const mat33n

  • mat33n(out: null | Vec, n: number): Vec

Const mat33to44

  • mat33to44(out: null | Vec, a: ReadonlyVec): Vec
  • Converts 3x3 to 4x4 matrix and writes result to out. Creates new matrix if out is null.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const mat33v

  • mat33v(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec, d: ReadonlyVec): Vec
  • Initializes 3x3 matrix from 3D column vectors.

    Parameters

    • a: null | Vec
    • b: ReadonlyVec
    • c: ReadonlyVec
    • d: ReadonlyVec

    Returns Vec

Const mat44n

  • mat44n(out: null | Vec, n: number): Vec

Const mat44to33

  • mat44to33(out: null | Vec, a: ReadonlyVec): Vec
  • Converts 4x4 to 3x3 matrix and writes result to out. Creates new matrix if out is null.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const mat44v

  • mat44v(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec, c: ReadonlyVec, d: ReadonlyVec): Vec
  • Initializes 4x4 matrix from 4D column vectors.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec
    • c: ReadonlyVec
    • d: ReadonlyVec

    Returns Vec

Const mixQ

  • mixQ(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec, t: number, eps?: number): Vec
  • Interpolates quaternion a to b by given amount t [0...1], using SLERP. Writes result to out. The optional eps (default 1e-3) is used to switch to linear interpolation if the angular difference is very small.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec
    • t: number
    • eps: number = 1e-3

    Returns Vec

Const mul22

  • mul22(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

mul23

  • mul23(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

mul33

  • mul33(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

mul44

  • mul44(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

Const mulM22

  • mulM22(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • 2x2 matrix-matrix multiplication. If out is not given, writes result in a.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulM23

  • mulM23(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • 2x3 matrix-matrix multiplication. If out is not given, writes result in a.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulM33

  • mulM33(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • 3x3 matrix-matrix multiplication. If out is not given, writes result in a.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulM44

  • mulM44(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • 4x4 matrix-matrix multiplication. If out is not given, writes result in a.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulN22

  • mulN22(out: null | Vec, a: ReadonlyVec, n: number): Vec

mulN23

  • mulN23(out: null | Vec, a: ReadonlyVec, n: number): Vec

mulN33

  • mulN33(out: null | Vec, a: ReadonlyVec, n: number): Vec

mulN44

  • mulN44(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const mulQ

  • mulQ(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec): Vec
  • Performs quaternion multiplication of a and b and writes result to out. If out is null, writes result into a.

    Parameters

    • a: null | Vec
    • b: ReadonlyVec
    • c: ReadonlyVec

    Returns Vec

Const mulV22

  • mulV22(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • Multiplies 2x2 matrix m with 2D vector v. Supports in-place modification, i.e. if out === v.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulV23

  • mulV23(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • Multiplies 2x3 matrix m with 2D vector v. Supports in-place modification, i.e. if out === v.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulV33

  • mulV33(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • Multiplies 3x3 matrix m with 3D vector v. Supports in-place modification, i.e. if out === v.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulV344

  • mulV344(out: null | Vec, m: ReadonlyVec, v: ReadonlyVec): undefined | Vec
  • Multiplies 4x4 matrix m with 3D vector v and assumes initial w=1, i.e. the vector is interpreted as [x,y,z,1]. After transformation applies perspective divide of the resulting XYZ components. Returns undefined if the computed perspective divisor is zero (and would cause NaN results).

    Parameters

    • out: null | Vec
    • m: ReadonlyVec
    • v: ReadonlyVec

    Returns undefined | Vec

Const mulV44

  • mulV44(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec
  • Multiplies 4x4 matrix m with 4D vector v. Supports in-place modification, i.e. if out === v.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • b: ReadonlyVec

    Returns Vec

Const mulVM22

  • mulVM22(out: null | Vec, v: ReadonlyVec, m: ReadonlyVec): Vec
  • Same as:

    example
    out[0] = dot(v, column(m, 0))
    out[1] = dot(v, column(m, 1))

    Parameters

    • out: null | Vec
    • v: ReadonlyVec
    • m: ReadonlyVec

    Returns Vec

Const mulVM23

  • mulVM23(out: null | Vec, v: ReadonlyVec, m: ReadonlyVec): Vec

Const mulVM33

  • mulVM33(out: null | Vec, v: ReadonlyVec, m: ReadonlyVec): Vec
  • Same as:

    example
    out[0] = dot(v, column(m, 0))
    out[1] = dot(v, column(m, 1))
    out[2] = dot(v, column(m, 2))

    Parameters

    • out: null | Vec
    • v: ReadonlyVec
    • m: ReadonlyVec

    Returns Vec

Const mulVM44

  • mulVM44(out: null | Vec, v: ReadonlyVec, m: ReadonlyVec): Vec
  • Same as:

    example
    out[0] = dot(v, column(m, 0))
    out[1] = dot(v, column(m, 1))
    out[2] = dot(v, column(m, 2))
    out[3] = dot(v, column(m, 3))

    Parameters

    • out: null | Vec
    • v: ReadonlyVec
    • m: ReadonlyVec

    Returns Vec

Const mulVQ

  • mulVQ(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec): Vec
  • Multiplies quaternion q with 3D vector v. Returns transformed vector or modifies in-place if out is null or v.

    Parameters

    • a: null | Vec
    • b: ReadonlyVec
    • c: ReadonlyVec

    Returns Vec

Const normal33

  • normal33(out: null | Vec, a: ReadonlyVec): undefined | Vec
  • Converts given 4x4 matrix to a 3x3 normal matrix, i.e. the transposed inverse of its upper-left 3x3 region. If out is null a new result matrix will be created. Returns undefined if matrix inversion failed.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns undefined | Vec

Const normal44

  • normal44(out: null | Vec, a: ReadonlyVec): undefined | Vec
  • Converts given 4x4 matrix to a 4x4 matrix normal matrix, i.e. the transposed inverse. Writes results to m if out is null. Returns undefined if matrix inversion failed.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns undefined | Vec

Const ortho

  • ortho(out: null | Vec, left: number, right: number, bottom: number, top: number, near: number, far: number): Vec
  • Creates a 4x4 matrix orthographic projection matrix and writes result to out.

    Parameters

    • out: null | Vec
    • left: number
    • right: number
    • bottom: number
    • top: number
    • near: number
    • far: number

    Returns Vec

Const outerProduct2

  • outerProduct2(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec): Vec

Const outerProduct3

  • outerProduct3(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec): Vec

Const outerProduct4

  • outerProduct4(a: null | Vec, b: ReadonlyVec, c: ReadonlyVec): Vec

Const perspective

  • perspective(out: null | Vec, fov: number, aspect: number, near: number, far: number): Vec
  • Creates a 4x4 matrix perspective projection matrix and writes result to out.

    Parameters

    • out: null | Vec
    • fov: number
    • aspect: number
    • near: number
    • far: number

    Returns Vec

Const project

  • project(out: null | Vec, mvp: ReadonlyVec, view: ReadonlyVec, p: ReadonlyVec): Vec
  • Transforms given point p (4D, homogeneous coordinates) with 4x4 matrix mvp, applies perspective divide and then transforms XY components with 2x3 matrix view matrix. Returns 3D vector. The result Z component can be used for depth sorting.

    Parameters

    • out: null | Vec
    • mvp: ReadonlyVec

      4x4 matrix

    • view: ReadonlyVec

      2x3 matrix

    • p: ReadonlyVec

    Returns Vec

Const project3

  • project3(out: null | Vec, mvp: ReadonlyVec, view: ReadonlyVec, p: ReadonlyVec): undefined | Vec
  • Same as project, but slightly faster and more convenient for the most common use case of projecting a 3D input point (assumes w=1 for its homogeneous coordinate, i.e. [x,y,z,1]). Returns undefined if the computed perspective divisor is zero (and would cause in NaN results).

    Parameters

    • out: null | Vec
    • mvp: ReadonlyVec

      4x4 matrix

    • view: ReadonlyVec

      2x3 matrix

    • p: ReadonlyVec

    Returns undefined | Vec

Const quatFromAxisAngle

  • quatFromAxisAngle(axis: ReadonlyVec, theta: number): Vec

Const quatFromEuler

  • quatFromEuler(order: "xyz" | "yxz" | "xzy" | "zxy" | "yzx" | "zyx", a: number, b: number, c: number): Vec
  • Constructs a quaternion from given rotation angles in specified order.

    Parameters

    • order: "xyz" | "yxz" | "xzy" | "zxy" | "yzx" | "zyx"
    • a: number
    • b: number
    • c: number

    Returns Vec

Const quatToAxisAngle

  • quatToAxisAngle(quat: ReadonlyVec): (number | number[])[]

Const quatToMat33

  • quatToMat33(out: null | Vec, a: ReadonlyVec): Vec
  • Converts quaternion into 3x3 matrix and writes result to out.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const quatToMat44

  • quatToMat44(out: null | Vec, a: ReadonlyVec, t?: ReadonlyVec): Vec
  • Converts quaternion into 4x4 matrix with optional 3D translation offset t, then writes result to out.

    Parameters

    • out: null | Vec
    • a: ReadonlyVec
    • t: ReadonlyVec = ...

    Returns Vec

Const rotation22

  • rotation22(out: null | Vec, n: number): Vec
  • Constructs a 2x2 matrix rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const rotation23

  • rotation23(out: null | Vec, n: number): Vec
  • Constructs a 2x3 matrix rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const rotationAroundAxis33

  • rotationAroundAxis33(out: null | Vec, axis: ReadonlyVec, theta: number, normalize?: boolean): Vec
  • Constructs a 3x3 matrix representing a rotation of theta around axis and writes result to out. If normalize is true (default false), non-destructively first normalizes axis vector.

    Parameters

    • out: null | Vec
    • axis: ReadonlyVec
    • theta: number
    • normalize: boolean = false

    Returns Vec

Const rotationAroundAxis44

  • rotationAroundAxis44(out: null | Vec, axis: ReadonlyVec, theta: number, normalize?: boolean): Vec
  • Constructs a 4x4 matrix representing a rotation of theta around axis and writes result to out. If normalize is true (default false), non-destructively first normalizes axis vector.

    Parameters

    • out: null | Vec
    • axis: ReadonlyVec
    • theta: number
    • normalize: boolean = false

    Returns Vec

Const rotationX33

  • rotationX33(out: null | Vec, n: number): Vec
  • Constructs a 3x3 matrix X rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const rotationX44

  • rotationX44(out: null | Vec, n: number): Vec
  • Constructs a 4x4 matrix X rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const rotationY33

  • rotationY33(out: null | Vec, n: number): Vec
  • Constructs a 3x3 matrix Y rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const rotationY44

  • rotationY44(out: null | Vec, n: number): Vec
  • Constructs a 4x4 matrix Y rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const rotationZ33

  • rotationZ33(out: null | Vec, n: number): Vec
  • Constructs a 3x3 matrix Z rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const rotationZ44

  • rotationZ44(out: null | Vec, n: number): Vec
  • Constructs a 4x4 matrix Z rotation matrix for given theta.

    Parameters

    • out: null | Vec
    • n: number

    Returns Vec

Const row22

  • row22(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const row23

  • row23(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const row33

  • row33(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const row44

  • row44(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const scale22

  • scale22(out: null | Vec, n: number | ReadonlyVec): Vec
  • Computes 2x2 matrix scale matrix and writes result to out. If s is a number, scaling will be uniform.

    Parameters

    • out: null | Vec
    • n: number | ReadonlyVec

    Returns Vec

Const scale23

  • scale23(out: null | Vec, n: number | ReadonlyVec): Vec
  • Computes 2x3 matrix scale matrix and writes result to out. If s is a number, scaling will be uniform.

    Parameters

    • out: null | Vec
    • n: number | ReadonlyVec

    Returns Vec

Const scale33

  • scale33(out: null | Vec, n: number | ReadonlyVec): Vec
  • Computes 3x3 matrix scale matrix and writes result to out. If s is a number, scaling will be uniform.

    Parameters

    • out: null | Vec
    • n: number | ReadonlyVec

    Returns Vec

Const scale44

  • scale44(out: null | Vec, n: number | ReadonlyVec): Vec
  • Computes 4x4 matrix scale matrix and writes result to out. If s is a number, scaling will be uniform.

    Parameters

    • out: null | Vec
    • n: number | ReadonlyVec

    Returns Vec

Const scaleWithCenter23

  • scaleWithCenter23(m: null | Vec, p: ReadonlyVec, s: number | ReadonlyVec): Vec
  • Computes a 2x3 matrix representing a scale operation with origin p and writes result to out.

    Parameters

    • m: null | Vec
    • p: ReadonlyVec
    • s: number | ReadonlyVec

    Returns Vec

Const scaleWithCenter44

  • scaleWithCenter44(m: null | Vec, p: ReadonlyVec, s: number | ReadonlyVec): Vec
  • Computes a 4x4 matrix representing a scale operation with origin p and writes result to out.

    Parameters

    • m: null | Vec
    • p: ReadonlyVec
    • s: number | ReadonlyVec

    Returns Vec

Const set

  • set(out: null | Vec, a: ReadonlyVec): Vec

Const set22

  • set22(out: null | Vec, a: ReadonlyVec): Vec

Const set23

  • set23(out: null | Vec, a: ReadonlyVec): Vec

Const set33

  • set33(out: null | Vec, a: ReadonlyVec): Vec

Const set44

  • set44(out: null | Vec, a: ReadonlyVec): Vec

Const shearX22

  • shearX22(out: null | Vec, n: number): Vec

Const shearX23

  • shearX23(out: null | Vec, n: number): Vec

Const shearXY33

  • shearXY33(out: null | Vec, n: number): Vec

Const shearXY44

  • shearXY44(out: null | Vec, n: number): Vec

Const shearXZ33

  • shearXZ33(out: null | Vec, n: number): Vec

Const shearXZ44

  • shearXZ44(out: null | Vec, n: number): Vec

Const shearY22

  • shearY22(out: null | Vec, n: number): Vec

Const shearY23

  • shearY23(out: null | Vec, n: number): Vec

Const shearYX33

  • shearYX33(out: null | Vec, n: number): Vec

Const shearYX44

  • shearYX44(out: null | Vec, n: number): Vec

Const shearYZ33

  • shearYZ33(out: null | Vec, n: number): Vec

Const shearYZ44

  • shearYZ44(out: null | Vec, n: number): Vec

Const shearZX33

  • shearZX33(out: null | Vec, n: number): Vec

Const shearZX44

  • shearZX44(out: null | Vec, n: number): Vec

Const shearZY33

  • shearZY33(out: null | Vec, n: number): Vec

Const shearZY44

  • shearZY44(out: null | Vec, n: number): Vec

Const skewX22

  • skewX22(out: null | Vec, n: number): Vec

Const skewX23

  • skewX23(out: null | Vec, n: number): Vec

Const skewXY33

  • skewXY33(out: null | Vec, n: number): Vec

Const skewXY44

  • skewXY44(out: null | Vec, n: number): Vec

Const skewXZ33

  • skewXZ33(out: null | Vec, n: number): Vec

Const skewXZ44

  • skewXZ44(out: null | Vec, n: number): Vec

Const skewY22

  • skewY22(out: null | Vec, n: number): Vec

Const skewY23

  • skewY23(out: null | Vec, n: number): Vec

Const skewYX33

  • skewYX33(out: null | Vec, n: number): Vec

Const skewYX44

  • skewYX44(out: null | Vec, n: number): Vec

Const skewYZ33

  • skewYZ33(out: null | Vec, n: number): Vec

Const skewYZ44

  • skewYZ44(out: null | Vec, n: number): Vec

Const skewZX33

  • skewZX33(out: null | Vec, n: number): Vec

Const skewZX44

  • skewZX44(out: null | Vec, n: number): Vec

Const skewZY33

  • skewZY33(out: null | Vec, n: number): Vec

Const skewZY44

  • skewZY44(out: null | Vec, n: number): Vec

Const sub22

  • sub22(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

sub23

  • sub23(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

sub33

  • sub33(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

sub44

  • sub44(out: null | Vec, a: ReadonlyVec, b: ReadonlyVec): Vec

Const subN22

  • subN22(out: null | Vec, a: ReadonlyVec, n: number): Vec

subN23

  • subN23(out: null | Vec, a: ReadonlyVec, n: number): Vec

subN33

  • subN33(out: null | Vec, a: ReadonlyVec, n: number): Vec

subN44

  • subN44(out: null | Vec, a: ReadonlyVec, n: number): Vec

Const trace

  • trace(m: ReadonlyVec): number
  • Returns matrix trace of m, i.e. component sum of diag(m).

    Parameters

    • m: ReadonlyVec

    Returns number

Const transform23

  • transform23(out: null | Vec, translate: ReadonlyVec, rotation: number, scale: number | ReadonlyVec): Vec
  • Creates 2x3 TRS transformation matrix from given translation vector, rotation angle and scale factor/vector.

    Parameters

    • out: null | Vec
    • translate: ReadonlyVec
    • rotation: number
    • scale: number | ReadonlyVec

    Returns Vec

Const transform44

  • transform44(out: null | Vec, translate: ReadonlyVec, rotation: ReadonlyVec, scale: number | ReadonlyVec): Vec
  • Creates 4x4 TRS transformation matrix from given translation vector, rotation angles (given as 3D vector) and scale factor/vector. Internally, uses a quaternion for constructing the rotation matrix part. The quaternion is created via quatFromEuler with ZYX ordering.

    Parameters

    • out: null | Vec
    • translate: ReadonlyVec
    • rotation: ReadonlyVec
    • scale: number | ReadonlyVec

    Returns Vec

Const translation23

  • translation23(m: null | Vec, v: ReadonlyVec): Vec

Const translation44

  • translation44(m: null | Vec, v: ReadonlyVec): Vec

Const transpose22

  • transpose22(out: null | Vec, a: ReadonlyVec): Vec
  • Writes transposition of 2x2 matrix m to out. Creates new matrix if out is null

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const transpose33

  • transpose33(out: null | Vec, a: ReadonlyVec): Vec
  • Writes transposition of 3x3 matrix m to out. Creates new matrix if out is null

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const transpose44

  • transpose44(out: null | Vec, a: ReadonlyVec): Vec
  • Writes transposition of 4x4 matrix m to out. Creates new matrix if out is null

    Parameters

    • out: null | Vec
    • a: ReadonlyVec

    Returns Vec

Const unproject

  • unproject(out: Vec, mvp: ReadonlyVec, view: ReadonlyVec, p: ReadonlyVec, doInvert?: boolean): undefined | Vec
  • Reverse operation of project3. If invert is true (default: false), both mvp and view matrices will be inverted first (non-destructively), else they're both assumed to be inverted already.

    Parameters

    • out: Vec
    • mvp: ReadonlyVec

      4x4 matrix

    • view: ReadonlyVec

      2x3 matrix

    • p: ReadonlyVec
    • doInvert: boolean = false

    Returns undefined | Vec

Const viewport

  • viewport(out: null | Vec, left: number, right: number, bottom: number, top: number): Vec
  • Produces a 2x3 viewport matrix to transform projected coordinates to screen space.

    Parameters

    • out: null | Vec
    • left: number
    • right: number
    • bottom: number
    • top: number

    Returns Vec

Generated using TypeDoc