Mat4 类型
继承于 ValueType
表示 4*4 矩阵
索引
属性(properties)
方法
mul将当前矩阵与指定矩阵相乘mulScalar将矩阵的每一个元素都乘以指定的缩放值。sub将当前矩阵与指定的矩阵相减clone获得指定矩阵的拷贝copy复制目标矩阵identity将目标赋值为单位矩阵transpose转置矩阵invert矩阵求逆determinant矩阵行列式multiply矩阵乘法transform在给定矩阵变换基础上加入变换translate在给定矩阵变换基础上加入新位移变换scale在给定矩阵变换基础上加入新缩放变换rotate在给定矩阵变换基础上加入新旋转变换rotateX在给定矩阵变换基础上加入绕 X 轴的旋转变换rotateY在给定矩阵变换基础上加入绕 Y 轴的旋转变换rotateZ在给定矩阵变换基础上加入绕 Z 轴的旋转变换fromTranslation计算位移矩阵fromScaling计算缩放矩阵fromRotation计算旋转矩阵fromXRotation计算绕 X 轴的旋转矩阵fromYRotation计算绕 Y 轴的旋转矩阵fromZRotation计算绕 Z 轴的旋转矩阵fromRT根据旋转和位移信息计算矩阵getTranslation提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用getScaling提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用getRotation提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用toRTS函数。toRTS提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用fromRTS根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用fromRTSOrigin根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用fromQuat根据指定的旋转信息计算矩阵frustum根据指定的视锥体信息计算矩阵perspective计算透视投影矩阵ortho计算正交投影矩阵lookAt根据视点计算矩阵,注意eye - center不能为零向量或与up向量平行inverseTranspose计算逆转置矩阵add逐元素矩阵加法subtract逐元素矩阵减法multiplyScalar矩阵标量乘法multiplyScalarAndAdd逐元素矩阵标量乘加: A + B * scalestrictEquals矩阵等价判断equals排除浮点数误差的矩阵近似等价判断toArray矩阵转数组fromArray数组转矩阵constructor构造函数,可查看 cc.mat4clone克隆一个 Mat4 对象set用另一个矩阵设置这个矩阵的值。equals当前的矩阵是否与指定的矩阵相等。fuzzyEquals近似判断两个矩阵是否相等。toString转换为方便阅读的字符串。identitySet the matrix to the identity matrixtransposeTranspose the values of a mat4invertInverts a mat4adjointCalculates the adjugate of a mat4determinantCalculates the determinant of a mat4addAdds two Mat4subtractSubtracts the current matrix with another onemultiplySubtracts the current matrix with another onemultiplyScalarMultiply each element of the matrix by a scalar.translateTranslate a mat4 by the given vectorscaleScales the mat4 by the dimensions in the given vec3rotateRotates a mat4 by the given angle around the given axisgetTranslationReturns the translation vector component of a transformation matrix.getScaleReturns the scale factor component of a transformation matrixgetRotationReturns the rotation factor component of a transformation matrixfromRTSRestore the matrix values from a quaternion rotation, vector translation and vector scalefromQuatRestore the matrix values from a quaternion rotationlerp线性插值。
Details
属性(properties)
IDENTITY
Identity of Mat4
| meta | description |
|---|---|
| 类型 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:86 |
m
矩阵数据
| meta | description |
|---|---|
| 类型 | Float64Array | Float32Array |
| 定义于 | cocos2d/core/value-types/mat4.ts:1641 |
方法
mul
将当前矩阵与指定矩阵相乘
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:52 |
参数列表
otherMat4 the second operandoutMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
mulScalar
将矩阵的每一个元素都乘以指定的缩放值。
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:63 |
参数列表
numberNumber amount to scale the matrix's elements byoutMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
sub
将当前矩阵与指定的矩阵相减
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:74 |
参数列表
otherMat4 the second operandoutMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
clone
获得指定矩阵的拷贝
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:93 |
copy
复制目标矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:111 |
identity
将目标赋值为单位矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:160 |
transpose
转置矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:189 |
invert
矩阵求逆
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:235 |
determinant
矩阵行列式
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:290 |
multiply
矩阵乘法
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:322 |
transform
在给定矩阵变换基础上加入变换
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:364 |
translate
在给定矩阵变换基础上加入新位移变换
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:398 |
scale
在给定矩阵变换基础上加入新缩放变换
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:424 |
rotate
在给定矩阵变换基础上加入新旋转变换
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:454 |
参数列表
radUnknown 旋转角度axisUnknown 旋转轴
rotateX
在给定矩阵变换基础上加入绕 X 轴的旋转变换
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:518 |
参数列表
radUnknown 旋转角度
rotateY
在给定矩阵变换基础上加入绕 Y 轴的旋转变换
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:564 |
参数列表
radUnknown 旋转角度
rotateZ
在给定矩阵变换基础上加入绕 Z 轴的旋转变换
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:610 |
参数列表
radUnknown 旋转角度
fromTranslation
计算位移矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:658 |
fromScaling
计算缩放矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:687 |
fromRotation
计算旋转矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:716 |
fromXRotation
计算绕 X 轴的旋转矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:762 |
fromYRotation
计算绕 Y 轴的旋转矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:794 |
fromZRotation
计算绕 Z 轴的旋转矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:826 |
fromRT
根据旋转和位移信息计算矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:858 |
getTranslation
提取矩阵的位移信息, 默认矩阵中的变换以 S->R->T 的顺序应用
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:903 |
getScaling
提取矩阵的缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:920 |
getRotation
提取矩阵的旋转信息, 默认输入矩阵不含有缩放信息,如考虑缩放应使用 toRTS 函数。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:948 |
toRTS
提取旋转、位移、缩放信息, 默认矩阵中的变换以 S->R->T 的顺序应用
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:990 |
fromRTS
根据旋转、位移、缩放信息计算矩阵,以 S->R->T 的顺序应用
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1019 |
fromRTSOrigin
根据指定的旋转、位移、缩放及变换中心信息计算矩阵,以 S->R->T 的顺序应用
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1067 |
参数列表
qUnknown 旋转值vUnknown 位移值sUnknown 缩放值oUnknown 指定变换中心
fromQuat
根据指定的旋转信息计算矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1124 |
frustum
根据指定的视锥体信息计算矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1172 |
参数列表
leftUnknown 左平面距离rightUnknown 右平面距离bottomUnknown 下平面距离topUnknown 上平面距离nearUnknown 近平面距离farUnknown 远平面距离
perspective
计算透视投影矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1211 |
参数列表
fovyUnknown 纵向视角高度aspectUnknown 长宽比nearUnknown 近平面距离farUnknown 远平面距离
ortho
计算正交投影矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1247 |
参数列表
leftUnknown 左平面距离rightUnknown 右平面距离bottomUnknown 下平面距离topUnknown 上平面距离nearUnknown 近平面距离farUnknown 远平面距离
lookAt
根据视点计算矩阵,注意 eye - center 不能为零向量或与 up 向量平行
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1285 |
参数列表
eyeUnknown 当前位置centerUnknown 目标视点upUnknown 视口上方向
inverseTranspose
计算逆转置矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1349 |
add
逐元素矩阵加法
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1410 |
subtract
逐元素矩阵减法
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1439 |
multiplyScalar
矩阵标量乘法
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1468 |
multiplyScalarAndAdd
逐元素矩阵标量乘加: A + B * scale
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1497 |
strictEquals
矩阵等价判断
| meta | description |
|---|---|
| 返回 | Bool |
| 定义于 | cocos2d/core/value-types/mat4.ts:1526 |
equals
排除浮点数误差的矩阵近似等价判断
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1543 |
toArray
矩阵转数组
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1607 |
参数列表
ofsUnknown 数组内的起始偏移量
fromArray
数组转矩阵
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1624 |
参数列表
ofsUnknown 数组起始偏移量
constructor
构造函数,可查看 cc.mat4
| meta | description |
|---|---|
| 定义于 | cocos2d/core/value-types/mat4.ts:1649 |
clone
克隆一个 Mat4 对象
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1689 |
set
用另一个矩阵设置这个矩阵的值。
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1705 |
参数列表
srcObjMat4
equals
当前的矩阵是否与指定的矩阵相等。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/value-types/mat4.ts:1735 |
参数列表
otherMat4
fuzzyEquals
近似判断两个矩阵是否相等。
判断 2 个矩阵是否在默认误差范围之内,如果在则返回 true,反之则返回 false。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/value-types/mat4.ts:1746 |
参数列表
otherMat4
toString
转换为方便阅读的字符串。
| meta | description |
|---|---|
| 返回 | string |
| 定义于 | cocos2d/core/value-types/mat4.ts:1759 |
identity
Set the matrix to the identity matrix
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1784 |
transpose
Transpose the values of a mat4
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1794 |
参数列表
outMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
invert
Inverts a mat4
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1805 |
参数列表
outMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
adjoint
Calculates the adjugate of a mat4
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1816 |
参数列表
outMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
determinant
Calculates the determinant of a mat4
| meta | description |
|---|---|
| 返回 | Number |
| 定义于 | cocos2d/core/value-types/mat4.ts:1827 |
add
Adds two Mat4
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1836 |
参数列表
otherMat4 the second operandoutMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created.
subtract
Subtracts the current matrix with another one
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1848 |
参数列表
otherMat4 the second operand
multiply
Subtracts the current matrix with another one
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1858 |
参数列表
otherMat4 the second operand
multiplyScalar
Multiply each element of the matrix by a scalar.
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1868 |
参数列表
numberNumber amount to scale the matrix's elements by
translate
Translate a mat4 by the given vector
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1878 |
参数列表
vVec3 vector to translate byoutMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
scale
Scales the mat4 by the dimensions in the given vec3
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1890 |
参数列表
vVec3 vector to scale byoutMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
rotate
Rotates a mat4 by the given angle around the given axis
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1902 |
参数列表
radNumber the angle to rotate the matrix byaxisVec3 the axis to rotate aroundoutMat4 the receiving matrix, you can pass the same matrix to save result to itself, if not provided, a new matrix will be created
getTranslation
Returns the translation vector component of a transformation matrix.
| meta | description |
|---|---|
| 返回 | Vec3 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1915 |
参数列表
outVec3 Vector to receive translation component, if not provided, a new vec3 will be created
getScale
Returns the scale factor component of a transformation matrix
| meta | description |
|---|---|
| 返回 | Vec3 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1926 |
参数列表
outVec3 Vector to receive scale component, if not provided, a new vec3 will be created
getRotation
Returns the rotation factor component of a transformation matrix
| meta | description |
|---|---|
| 返回 | Quat |
| 定义于 | cocos2d/core/value-types/mat4.ts:1937 |
参数列表
outQuat Vector to receive rotation component, if not provided, a new quaternion object will be created
fromRTS
Restore the matrix values from a quaternion rotation, vector translation and vector scale
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1948 |
参数列表
fromQuat
Restore the matrix values from a quaternion rotation
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/value-types/mat4.ts:1961 |
参数列表
qQuat Rotation quaternion
lerp
线性插值。
当 ratio = 0 时返回自身,ratio = 1 时返回目标,ratio = 0.5 返回自身和目标的平均值。。
| meta | description |
|---|---|
| 返回 | ValueType |
| 定义于 | cocos2d/core/value-types/value-type.ts:63 |