Skip to main content

Class: Matrix4

一个表示 4*4 的矩阵 1--0--0--0 | | | | 0--1--0--0 | | | | 0--0--1--0 | | | | 0--0--0--1

const m = new Matrix4();

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Matrix4(m00?, m01?, m02?, m03?, m10?, m11?, m12?, m13?, m20?, m21?, m22?, m23?, m30?, m31?, m32?, m33?): Matrix4

Parameters

NameTypeDefault valueDescription
m00number1第一行第一列,默认是 1
m01number0第一行第二列,默认是 0
m02number0第一行第三列,默认是 0
m03number0第一行第四列,默认是 0
m10number0第二行第一列,默认是 0
m11number1第二行第二列,默认是 1
m12number0第二行第三列,默认是 0
m13number0第二行第四列,默认是 0
m20number0第三行第一列,默认是 0
m21number0第三行第二列,默认是 0
m22number1第三行第三列,默认是 1
m23number0第三行第四列,默认是 0
m30number0第四行第一列,默认是 0
m31number0第四行第二列,默认是 0
m32number0第四行第三列,默认是 0
m33number1第四行第四列,默认是 1

Returns

Matrix4

Overrides

Matrix.constructor

Defined in

src/math/Matrix4.ts:77

Properties

elements

elements: Float32Array | Float64Array

Overrides

Matrix.elements

Defined in

src/math/Matrix4.ts:57

Accessors

x

get x(): number

获取向量 x 值

Returns

number

number;

Defined in

src/math/Matrix4.ts:123


y

get y(): number

获取向量 y 值

Returns

number

number;

Defined in

src/math/Matrix4.ts:131


z

get z(): number

获取向量 z 值

Returns

number

number;

Defined in

src/math/Matrix4.ts:139


w

get w(): number

获取向量 w 值

Returns

number

number;

Defined in

src/math/Matrix4.ts:147


identity

get identity(): Matrix4

获取单位矩阵

Returns

Matrix4

Defined in

src/math/Matrix4.ts:154

Methods

fromArray

fromArray(array, offset?): Matrix4

从数组构建矩阵

Parameters

NameTypeDefault valueDescription
arrayanyundefined原始数组
offsetnumber0数组偏移量

Returns

Matrix4

Inherited from

Matrix.fromArray

Defined in

src/math/Matrix.ts:15


toArray

toArray(out?, offset?): Float32Array | Float64Array | number[]

从矩阵转换到数组

Parameters

NameTypeDefault valueDescription
outFloat32Array | Float64Array | number[][]输出数据
offsetnumber0偏移量

Returns

Float32Array | Float64Array | number[]

Inherited from

Matrix.toArray

Defined in

src/math/Matrix.ts:28


set

set(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33): Matrix4

将此矩阵的每一项设置为给定的值

Parameters

NameType
m00any
m01any
m02any
m03any
m10any
m11any
m12any
m13any
m20any
m21any
m22any
m23any
m30any
m31any
m32any
m33any

Returns

Matrix4

Defined in

src/math/Matrix4.ts:177


transpose

transpose(): Matrix4

将此矩阵转换为转置矩阵

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:186


invert

invert(m?): Matrix4

将此矩阵转换为逆矩阵

Parameters

NameTypeDescription
mMatrix4默认为当前实例

Returns

Matrix4

Matrix4

Defined in

src/math/Matrix4.ts:196


adjoint

adjoint(m?): Matrix4

计算此矩阵的伴随矩阵

Parameters

NameTypeDescription
mMatrix4默认为当前实例

Returns

Matrix4

Defined in

src/math/Matrix4.ts:205


determinant

determinant(): any

计算行列式

Returns

any

Defined in

src/math/Matrix4.ts:214


add

add(a, b?): Matrix4

将两个 Matrix4 矩阵相加

Parameters

NameTypeDescription
aMatrix4
b?Matrix4如果不传,计算 this 和 a 的和

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:224


subtract

subtract(a, b?): Matrix4

将两个 Matrix4 矩阵相减

Parameters

NameTypeDescription
aMatrix4
b?Matrix4如果不传,计算 this 和 a 的差

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:240


multiply

multiply(a, b?): Matrix4

计算两个 Matrix4 矩阵的乘积

Parameters

NameTypeDescription
aMatrix4
b?Matrix4如果不传,计算 this 和 a 的乘积

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:255


multiplyScalar

multiplyScalar(a?, b?): Matrix4

计算 Matrix4 与标量的乘积

Parameters

NameTypeDescription
aMatrix4如果不传,计算 this 和 b 的乘积
b?number

Returns

Matrix4

Defined in

src/math/Matrix4.ts:269


premultiply

premultiply(a, b?): Matrix4

左乘

Parameters

NameTypeDescription
aMatrix4
b?Matrix4如果不传,计算 this 和 a 的左乘

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:280


translate

translate(v): Matrix4

通过给定的向量 Vector3 平移此矩阵

Parameters

NameTypeDescription
vVector3向量

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:294


rotate

rotate(rad): Matrix4

旋转此矩阵

Parameters

NameTypeDescription
radnumber弧度

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:304


scale

scale(vec3): Matrix4

通过给定的 Vector3 向量缩放此矩阵

Parameters

NameType
vec3Vector3

Returns

Matrix4

Defined in

src/math/Matrix4.ts:313


scaleScalar

scaleScalar(s): Matrix4

通过标量 s 缩放此矩阵,默认在内部构建一个三维向量 [s, s, s]

Parameters

NameType
snumber

Returns

Matrix4

Defined in

src/math/Matrix4.ts:322


fromTranslation

fromTranslation(vec): Matrix4

从平移向量创建矩阵

Parameters

NameType
vecVector3

Returns

Matrix4

Defined in

src/math/Matrix4.ts:331


fromRotation

fromRotation(rad, axis): Matrix4

从给定轴和旋转角度创建矩阵

Parameters

NameTypeDescription
radnumber弧度
axisany

Returns

Matrix4

Defined in

src/math/Matrix4.ts:341


fromRotationX

fromRotationX(rad): Matrix4

从绕 X 轴的给定角度创建矩阵

Parameters

NameType
radnumber

Returns

Matrix4

Defined in

src/math/Matrix4.ts:350


fromRotationY

fromRotationY(rad): Matrix4

从绕 Y 轴的给定角度创建矩阵

Parameters

NameType
radnumber

Returns

Matrix4

Defined in

src/math/Matrix4.ts:359


fromRotationZ

fromRotationZ(rad): Matrix4

从绕 Z 轴的给定角度创建矩阵

Parameters

NameType
radany

Returns

Matrix4

Defined in

src/math/Matrix4.ts:368


fromScale

fromScale(vec): Matrix4

从缩放向量计算矩阵

Parameters

NameType
vecVector3

Returns

Matrix4

Defined in

src/math/Matrix4.ts:377


fromRotationTranslation

fromRotationTranslation(quat, v): Matrix4

从平移向量和四元数计算矩阵

Parameters

NameType
quatQuaternion
vVector3

Returns

Matrix4

Defined in

src/math/Matrix4.ts:387


fromPerspective

fromPerspective(fov, aspect, near, far): Matrix4

创建一个透视投影矩阵

Parameters

NameType
fovany
aspectany
nearany
farany

Returns

Matrix4

Defined in

src/math/Matrix4.ts:399


fromOrthogonal

fromOrthogonal(left, right, bottom, top, near, far): Matrix4

创建一个正交投影矩阵

Parameters

NameType
leftany
rightany
bottomany
topany
nearany
farany

Returns

Matrix4

Defined in

src/math/Matrix4.ts:413


fromQuat

fromQuat(q): Matrix4

从给定的四元数计算矩阵

Parameters

NameType
qQuaternion

Returns

Matrix4

Defined in

src/math/Matrix4.ts:422


equals

equals(mat4): any

判断两个矩阵是否近似相等

Parameters

NameType
mat4any

Returns

any

Defined in

src/math/Matrix4.ts:431


getRotation

getRotation(q?): Quaternion

获取旋转向量

Parameters

NameType
qQuaternion

Returns

Quaternion

Defined in

src/math/Matrix4.ts:439


getScale

getScale(v?): Vector3

获取缩放向量

Parameters

NameType
vVector3

Returns

Vector3

Defined in

src/math/Matrix4.ts:449


getTranslation

getTranslation(v?): Vector3

获取平移向量

Parameters

NameType
vVector3

Returns

Vector3

Defined in

src/math/Matrix4.ts:459


rotateX

rotateX(rad): Matrix4

围绕 X 轴按给定弧度旋转矩阵

Parameters

NameType
radany

Returns

Matrix4

Defined in

src/math/Matrix4.ts:469


rotateY

rotateY(rad): Matrix4

围绕 Y 轴按给定弧度旋转矩阵

Parameters

NameType
radany

Returns

Matrix4

Defined in

src/math/Matrix4.ts:478


rotateZ

rotateZ(rad): Matrix4

围绕 Z 轴按给定弧度旋转矩阵

Parameters

NameType
radany

Returns

Matrix4

Defined in

src/math/Matrix4.ts:487


compose

compose(v, q, s): Matrix4

从四元数旋转、平移和缩放创建矩阵

Parameters

NameType
vVector3
qQuaternion
sVector3

Returns

Matrix4

Defined in

src/math/Matrix4.ts:498


decompose

decompose(): Object

从矩阵转换到四元数、平移和缩放向量

Returns

Object

NameType
rotationQuaternion
scaleVector3
translationVector3

Defined in

src/math/Matrix4.ts:506


copy

copy(m): Matrix4

将传入的 Matrix4 复制到此矩阵

Parameters

NameTypeDescription
mMatrix4源矩阵

Returns

Matrix4

this

Defined in

src/math/Matrix4.ts:519


clone

clone(): Matrix4

从此矩阵创建一个新的 4*4 矩阵

Returns

Matrix4

a new Matrix4

Defined in

src/math/Matrix4.ts:528


toString

toString(): string

转换为字符串

Returns

string

Defined in

src/math/Matrix4.ts:535