Class: Matrix3
一个表示 3*3 的矩阵 1--0--0 | | | 0--1--0 | | | 0--0--1
const m = new Matrix3();
Hierarchy
-
default↳
Matrix3
Table of contents
Constructors
Properties
Accessors
Methods
- fromArray
- toArray
- set
- transpose
- invert
- adjoint
- determinant
- multiply
- premultiply
- translate
- rotate
- scale
- fromTranslation
- fromRotation
- fromScaling
- fromQuat
- normalFromMat4
- fromMat4
- frob
- add
- subtract
- equals
- fromRotationTranslationScale
- getNormalMatrix
- copy
- clone
- toString
Constructors
constructor
• new Matrix3(m00?, m01?, m02?, m10?, m11?, m12?, m20?, m21?, m22?): Matrix3
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
m00 | number | 1 | 第一行第一列,默认是 1 |
m01 | number | 0 | 第一行第二列,默认是 0 |
m02 | number | 0 | 第一行第三列,默认是 0 |
m10 | number | 0 | 第二行第一列,默认是 0 |
m11 | number | 1 | 第二行第二列,默认是 1 |
m12 | number | 0 | 第二行第三列,默认是 0 |
m20 | number | 0 | 第三行第一列,默认是 0 |
m21 | number | 0 | 第三行第二列,默认是 0 |
m22 | number | 1 | 第三行第三列,默认是 1 |
Returns
Overrides
Matrix.constructor
Defined in
Properties
elements
• elements: Float32Array | Float64Array
Overrides
Matrix.elements
Defined in
Accessors
x
• get x(): number
获取向量 x 值
Returns
number
number;
Defined in
y
• get y(): number
获取向量 y 值
Returns
number
number;
Defined in
z
• get z(): number
获取向量 z 值
Returns
number
number;
Defined in
identity
• get identity(): Matrix3
获取单位矩阵
Returns
Defined in
Methods
fromArray
▸ fromArray(array, offset?): Matrix3
从数组构建矩阵
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
array | any | undefined | 原始数组 |
offset | number | 0 | 数组偏移量 |
Returns
Inherited from
Matrix.fromArray
Defined in
toArray
▸ toArray(out?, offset?): Float32Array | Float64Array | number[]
从矩阵转换到数组
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
out | Float32Array | Float64Array | number[] | [] | 输出数据 |
offset | number | 0 | 偏移量 |
Returns
Float32Array | Float64Array | number[]
Inherited from
Matrix.toArray
Defined in
set
▸ set(m00, m01, m02, m10, m11, m12, m20, m21, m22): Matrix3
将此矩阵的每一项设置为给定的值
Parameters
| Name | Type |
|---|---|
m00 | any |
m01 | any |
m02 | any |
m10 | any |
m11 | any |
m12 | any |
m20 | any |
m21 | any |
m22 | any |
Returns
this
Defined in
transpose
▸ transpose(): Matrix3
将此矩阵转换为转置矩阵
Returns
this
Defined in
invert
▸ invert(m?): Matrix3
将此矩阵转换为逆矩阵
Parameters
| Name | Type |
|---|---|
m? | Matrix3 |
Returns
this
Defined in
adjoint
▸ adjoint(m?): Matrix3
计算此矩阵的伴随矩阵
Parameters
| Name | Type |
|---|---|
m? | Matrix3 |
Returns
this
Defined in
determinant
▸ determinant(): any
计算行列式
Returns
any
Defined in
multiply
▸ multiply(a, b?): Matrix3
计算两个Matrix3矩阵的乘积
Parameters
| Name | Type | Description |
|---|---|---|
a | Matrix3 | |
b? | Matrix3 | 如果不传,计算 this 和 a 的乘积 |
Returns
this
Defined in
premultiply
▸ premultiply(a, b?): Matrix3
左乘
Parameters
| Name | Type | Description |
|---|---|---|
a | Matrix3 | |
b? | Matrix3 | 如果不传,计算 this 和 a 的左乘 |
Returns
this
Defined in
translate
▸ translate(v): Matrix3
通过给定的向量 Vector2 平移此矩阵
Parameters
| Name | Type | Description |
|---|---|---|
v | Vector2 | 向量 |
Returns
this
Defined in
rotate
▸ rotate(rad): Matrix3
旋转此矩阵
Parameters
| Name | Type | Description |
|---|---|---|
rad | number | 弧度 |
Returns
this
Defined in
scale
▸ scale(v): Matrix3
通过给定的 Vector2 向量缩放此矩阵
Parameters
| Name | Type | Description |
|---|---|---|
v | Vector2 | 向量 |
Returns
this
Defined in
fromTranslation
▸ fromTranslation(v): Matrix3
计算单位矩阵平移后的矩阵
Parameters
| Name | Type | Description |
|---|---|---|
v | Vector2 | 平移的向量 |
Returns
this
Defined in
fromRotation
▸ fromRotation(rad): Matrix3
计算单位矩阵旋转后的矩阵
Parameters
| Name | Type | Description |
|---|---|---|
rad | number | 旋转弧度 |
Returns
this
Defined in
fromScaling
▸ fromScaling(v): Matrix3
计算单位矩阵缩放后的矩阵
Parameters
| Name | Type | Description |
|---|---|---|
v | any | Scaling vector |
Returns
this
Defined in
fromQuat
▸ fromQuat(q): Matrix3
根据给定的四元数计算矩阵
Parameters
| Name | Type | Description |
|---|---|---|
q | Quaternion | Quaternion to create matrix from |
Returns
this
Defined in
normalFromMat4
▸ normalFromMat4(m): Matrix3
从 4x4 矩阵计算 3x3 正态矩阵(转置逆矩阵)
Parameters
| Name | Type | Description |
|---|---|---|
m | any | 给定的 Matrix4 矩阵 |
Returns
this
Defined in
fromMat4
▸ fromMat4(m): Matrix3
将 Matrix4 左上角的 3x3 值复制到给定的 Matrix3 中。
Parameters
| Name | Type | Description |
|---|---|---|
m | any | 源矩阵 |
Returns
this
Defined in
frob
▸ frob(): any
计算此矩阵的 Frobenius 范数
Returns
any
Frobenius 范数
Defined in
add
▸ add(a, b?): Matrix3
将两个 Matrix3 矩阵相加
Parameters
| Name | Type | Description |
|---|---|---|
a | Matrix3 | |
b? | Matrix3 | 如果不传,计算 this 和 a 的和 |
Returns
this
Defined in
subtract
▸ subtract(a, b?): Matrix3
将两个 Matrix3 矩阵相减
Parameters
| Name | Type | Description |
|---|---|---|
a | Matrix3 | |
b? | Matrix3 | 如果不传,计算 this 和 a 的差 |
Returns
this
Defined in
equals
▸ equals(a, b?): any
判断两个矩阵是否近似相等
Parameters
| Name | Type | Description |
|---|---|---|
a | Matrix3 | |
b? | Matrix3 | 如果不传,比较 this 和 a 是否近似相等 |
Returns
any
Defined in
fromRotationTranslationScale
▸ fromRotationTranslationScale(rotation, x, y, scaleX, scaleY): Matrix3
从给定的旋转角度,位置(二维向量),缩放计算矩阵
Parameters
| Name | Type |
|---|---|
rotation | any |
x | any |
y | any |
scaleX | any |
scaleY | any |
Returns
Defined in
getNormalMatrix
▸ getNormalMatrix(m): Matrix3
从 4x4 矩阵计算 3x3 正态矩阵(转置逆矩阵) 这个值传递给着色器,用于计算物体的光照。 它是物体的modelViewMatrix矩阵中,左上角3x3子矩阵的逆的转置矩阵
Parameters
| Name | Type |
|---|---|
m | Matrix4 |
Returns
Defined in
copy
▸ copy(m): Matrix3
将传入的 Matrix3 复制到此矩阵
Parameters
| Name | Type | Description |
|---|---|---|
m | Matrix3 | 源矩阵 |
Returns
this
Defined in
clone
▸ clone(): Matrix3
从此矩阵创建一个新的 3*3 矩阵
Returns
a new Matrix3
Defined in
toString
▸ toString(): string
转换为字符串
Returns
string