Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mat4

表示四维(4x4)矩阵。

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

矩阵第 0 列第 0 行的元素。

m01

m01: number

矩阵第 0 列第 1 行的元素。

m02

m02: number

矩阵第 0 列第 2 行的元素。

m03

m03: number

矩阵第 0 列第 3 行的元素。

m04

m04: number

矩阵第 1 列第 0 行的元素。

m05

m05: number

矩阵第 1 列第 1 行的元素。

m06

m06: number

矩阵第 1 列第 2 行的元素。

m07

m07: number

矩阵第 1 列第 3 行的元素。

m08

m08: number

矩阵第 2 列第 0 行的元素。

m09

m09: number

矩阵第 2 列第 1 行的元素。

m10

m10: number

矩阵第 2 列第 2 行的元素。

m11

m11: number

矩阵第 2 列第 3 行的元素。

m12

m12: number

矩阵第 3 列第 0 行的元素。

m13

m13: number

矩阵第 3 列第 1 行的元素。

m14

m14: number

矩阵第 3 列第 2 行的元素。

m15

m15: number

矩阵第 3 列第 3 行的元素。

Static IDENTITY

IDENTITY: {} = Object.freeze(new Mat4())

Type declaration

Methods

add

  • add(mat: Mat4): this
  • 矩阵加法。将当前矩阵与指定矩阵的相加,结果返回给当前矩阵。

    Parameters

    • mat: Mat4

      the second operand

    Returns this

clone

determinant

  • determinant(): number

equals

  • equals(other: Mat4, epsilon?: number): boolean
  • 判断当前矩阵是否在误差范围内与指定矩阵相等。

    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 returnsfalse'.

fromQuat

  • fromQuat(q: Quat): this
  • 重置当前矩阵的值,使其表示指定四元数表示的旋转变换。

    Parameters

    • q: Quat

      Rotation quaternion

    Returns this

    this

fromRTS

  • 重置当前矩阵的值,使其表示指定的旋转、缩放、位移依次组合的变换。

    Parameters

    • q: Quat

      Rotation quaternion

    • v: Vec3

      Translation vector

    • s: Vec3

      Scaling vector

    Returns this

    this

getRotation

  • 从当前矩阵中计算出旋转变换的部分,并以四元数的形式赋值给出口四元数。

    Parameters

    • out: Quat

      Vector to receive rotation component

    Returns Quat

getScale

  • 从当前矩阵中计算出缩放变换的部分,并以各个轴上缩放的形式赋值给出口向量。

    Parameters

    • out: Vec3

      Vector to receive scale component

    Returns Vec3

getTranslation

  • 从当前矩阵中计算出位移变换的部分,并以各个轴上位移的形式赋值给出口向量。

    Parameters

    • out: Vec3

      Vector to receive translation component.

    Returns Vec3

identity

  • identity(): this

invert

  • invert(): this
  • 计算当前矩阵的逆矩阵。注意,在矩阵不可逆时,会返回一个全为 0 的矩阵。

    Returns this

multiply

  • multiply(mat: Mat4): this
  • 矩阵乘法。将当前矩阵左乘指定矩阵的结果赋值给当前矩阵。

    Parameters

    • mat: Mat4

      the second operand

    Returns this

multiplyScalar

  • multiplyScalar(scalar: number): this
  • 矩阵数乘。将当前矩阵与指定标量的数乘结果赋值给当前矩阵。

    Parameters

    • scalar: number

      amount to scale the matrix's elements by

    Returns this

rotate

  • rotate(rad: number, axis: Vec3): null | this
  • 将当前矩阵左乘旋转矩阵的结果赋值给当前矩阵,旋转矩阵由旋转轴和旋转角度给出。

    Parameters

    • rad: number

      Angle of rotation (in radians)

    • axis: Vec3

      Axis of rotation

    Returns null | this

scale

  • scale(vec: Vec3): this
  • 将当前矩阵左乘缩放矩阵的结果赋值给当前矩阵,缩放矩阵由各个轴的缩放给出。

    Parameters

    • vec: Vec3

      vector to scale by

    Returns 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
  • 设置当前矩阵使其与指定矩阵相等。

    Parameters

    • other: Mat4

      Specified matrix.

    Returns any

    this

  • 设置当前矩阵指定元素值。

    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
  • 判断当前矩阵是否与指定矩阵相等。

    Parameters

    • other: Mat4

      Comparative matrix

    Returns boolean

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

subtract

  • subtract(mat: Mat4): this
  • 计算矩阵减法。将当前矩阵减去指定矩阵的结果赋值给当前矩阵。

    Parameters

    • mat: Mat4

      the second operand

    Returns this

toString

  • toString(): string

translate

  • translate(vec: Vec3): this
  • 将当前矩阵左乘位移矩阵的结果赋值给当前矩阵,位移矩阵由各个轴的位移给出。

    Parameters

    • vec: Vec3

      vector to translate by

    Returns 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
  • 排除浮点数误差的矩阵近似等价判断

    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
  • 数组转矩阵

    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
  • 根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用

    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
  • 根据指定的视锥体信息计算矩阵

    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
  • 提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 toRTS 函数。

    Type parameters

    Parameters

    • out: Quat
    • mat: Out

    Returns Quat

Static getScaling

  • getScaling<Out, VecLike>(out: VecLike, mat: Out): VecLike

Static getTranslation

  • getTranslation<Out, VecLike>(out: VecLike, mat: Out): VecLike

Static identity

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

Static inverseTranspose

  • inverseTranspose<Out>(out: Out, a: Out): null | Out

Static invert

  • invert<Out>(out: Out, a: Out): Out
  • 矩阵求逆,注意,在矩阵不可逆时,会返回一个全为 0 的矩阵。

    Type parameters

    Parameters

    • out: Out
    • a: Out

    Returns Out

Static lookAt

  • lookAt<Out, VecLike>(out: Out, eye: VecLike, center: VecLike, up: VecLike): Out
  • 根据视点计算矩阵,注意 eye - center 不能为零向量或与 up 向量平行

    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

Static multiplyScalarAndAdd

  • multiplyScalarAndAdd<Out>(out: Out, a: Out, b: Out, scale: number): 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
  • 计算正交投影矩阵

    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
  • 计算透视投影矩阵

    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
  • 在给定矩阵变换基础上加入新旋转变换

    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
  • 在给定矩阵变换基础上加入绕 X 轴的旋转变换

    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
  • 在给定矩阵变换基础上加入绕 Y 轴的旋转变换

    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
  • 在给定矩阵变换基础上加入绕 Z 轴的旋转变换

    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

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
  • 设置矩阵值

    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

Static toArray

  • toArray<Out>(out: Out, m: IMat4Like, ofs?: number): Out
  • 矩阵转数组

    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

Static transform

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

Static translate

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

Static transpose

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

Generated using TypeDoc