new Cesium.Matrix4(column0Row0, column1Row0, column2Row0, column3Row0, column0Row1, column1Row1, column2Row1, column3Row1, column0Row2, column1Row2, column2Row2, column3Row2, column0Row3, column1Row3, column2Row3, column3Row3)
| Name | Type | Default | Description |
|---|---|---|---|
column0Row0 |
number |
0.0
|
optional 第 0 列第 0 行的值。 |
column1Row0 |
number |
0.0
|
optional 第 1 列第 0 行的值。 |
column2Row0 |
number |
0.0
|
optional 第 2 列第 0 行的值。 |
column3Row0 |
number |
0.0
|
optional 第 3 列第 0 行的值。 |
column0Row1 |
number |
0.0
|
optional 第 0 列第 1 行的值。 |
column1Row1 |
number |
0.0
|
optional 第 1 列第 1 行的值。 |
column2Row1 |
number |
0.0
|
optional 第 2 列第 1 行的值。 |
column3Row1 |
number |
0.0
|
optional 第 3 列第 1 行的值。 |
column0Row2 |
number |
0.0
|
optional 第 0 列第 2 行的值。 |
column1Row2 |
number |
0.0
|
optional 第 1 列第 2 行的值。 |
column2Row2 |
number |
0.0
|
optional 第 2 列第 2 行的值。 |
column3Row2 |
number |
0.0
|
optional 第 3 列第 2 行的值。 |
column0Row3 |
number |
0.0
|
optional 第 0 列第 3 行的值。 |
column1Row3 |
number |
0.0
|
optional 第 1 列第 3 行的值。 |
column2Row3 |
number |
0.0
|
optional 第 2 列第 3 行的值。 |
column3Row3 |
number |
0.0
|
optional 第 3 列第 3 行的值。 |
- Matrix4.fromArray
- Matrix4.fromColumnMajorArray
- Matrix4.fromRowMajorArray
- Matrix4.fromRotationTranslation
- Matrix4.fromTranslationQuaternionRotationScale
- Matrix4.fromTranslationRotationScale
- Matrix4.fromTranslation
- Matrix4.fromScale
- Matrix4.fromUniformScale
- Matrix4.fromRotation
- Matrix4.fromCamera
- Matrix4.computePerspectiveFieldOfView
- Matrix4.computeOrthographicOffCenter
- Matrix4.computePerspectiveOffCenter
- Matrix4.computeInfinitePerspectiveOffCenter
- Matrix4.computeViewportTransformation
- Matrix4.computeView
- Matrix2
- Matrix3
- Packable
See:
Members
获取集合中的项目数量。
Matrix4 中第 0 列第 0 行的索引。
Matrix4 中第 0 列第 1 行的索引。
Matrix4 中第 0 列第 2 行的索引。
Matrix4 中第 0 列第 3 行的索引。
Matrix4 中第 1 列第 0 行的索引。
Matrix4 中第 1 列第 1 行的索引。
Matrix4 中第 1 列第 2 行的索引。
Matrix4 中第 1 列第 3 行的索引。
Matrix4 中第 2 列第 0 行的索引。
Matrix4 中第 2 列第 1 行的索引。
Matrix4 中第 2 列第 2 行的索引。
Matrix4 中第 2 列第 3 行的索引。
Matrix4 中第 3 列第 0 行的索引。
Matrix4 中第 3 列第 1 行的索引。
Matrix4 中第 3 列第 2 行的索引。
Matrix4 中第 3 列第 3 行的索引。
static constant Cesium.Matrix4.IDENTITY : Matrix4
初始化为单位矩阵的不可变 Matrix4 实例。
将对象打包到数组中时使用的元素数量。
static constant Cesium.Matrix4.ZERO : Matrix4
初始化为零矩阵的不可变 Matrix4 实例。
Methods
clone(result) → Matrix4
复制提供的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
result |
Matrix4 | optional 用于存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
逐分量比较此矩阵与提供的矩阵,如果
相等则返回
true,否则返回 false。
| Name | Type | Description |
|---|---|---|
right |
Matrix4 | optional 右侧矩阵。 |
Returns:
如果相等则为
true,否则为 false。
逐分量比较此矩阵与提供的矩阵,如果
它们在提供的 epsilon 范围内则返回
true,
否则返回 false。
| Name | Type | Default | Description |
|---|---|---|---|
right |
Matrix4 | optional 右侧矩阵。 | |
epsilon |
number |
0
|
optional 用于相等性测试的 epsilon。 |
Returns:
如果它们在提供的 epsilon 范围内则为
true,否则为 false。
创建表示此矩阵的字符串,每行位于
单独的一行,格式为 '(column0, column1, column2, column3)'。
Returns:
表示此矩阵的字符串,每行位于单独的一行,格式为 '(column0, column1, column2, column3)'。
static Cesium.Matrix4.abs(matrix, result) → Matrix4
计算一个矩阵,其中包含提供矩阵元素的绝对(无符号)值。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 带有带符号元素的矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.add(left, right, result) → Matrix4
计算两个矩阵的和。
| Name | Type | Description |
|---|---|---|
left |
Matrix4 | 第一个矩阵。 |
right |
Matrix4 | 第二个矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.clone(matrix, result) → Matrix4
复制 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要复制的矩阵。 |
result |
Matrix4 | optional 用于存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。(如果 matrix 为 undefined 则返回 undefined)
static Cesium.Matrix4.computeInfinitePerspectiveOffCenter(left, right, bottom, top, near, result) → Matrix4
计算表示无限偏移中心透视变换的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
left |
number | 相机左侧可见区域的米数。 |
right |
number | 相机右侧可见区域的米数。 |
bottom |
number | 相机下方可见区域的米数。 |
top |
number | 相机上方可见区域的米数。 |
near |
number | 到近平面的距离(米)。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.computeOrthographicOffCenter(left, right, bottom, top, near, far, result) → Matrix4
计算表示正交变换矩阵的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
left |
number | 相机左侧可见区域的米数。 |
right |
number | 相机右侧可见区域的米数。 |
bottom |
number | 相机下方可见区域的米数。 |
top |
number | 相机上方可见区域的米数。 |
near |
number | 到近平面的距离(米)。 |
far |
number | 到远平面的距离(米)。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.computePerspectiveFieldOfView(fovY, aspectRatio, near, far, result) → Matrix4
计算表示透视变换矩阵的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
fovY |
number | 沿 Y 轴的视野(弧度)。 |
aspectRatio |
number | 宽高比。 |
near |
number | 到近平面的距离(米)。 |
far |
number | 到远平面的距离(米)。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError : fovY 必须在 (0, PI] 范围内。
-
DeveloperError : aspectRatio 必须大于零。
-
DeveloperError : near 必须大于零。
-
DeveloperError : far 必须大于零。
static Cesium.Matrix4.computePerspectiveOffCenter(left, right, bottom, top, near, far, result) → Matrix4
计算表示偏移中心透视变换的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
left |
number | 相机左侧可见区域的米数。 |
right |
number | 相机右侧可见区域的米数。 |
bottom |
number | 相机下方可见区域的米数。 |
top |
number | 相机上方可见区域的米数。 |
near |
number | 到近平面的距离(米)。 |
far |
number | 到远平面的距离(米)。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.computeView(position, direction, up, right, result) → Matrix4
计算从世界空间变换到视图空间的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
position |
Cartesian3 | 相机位置。 |
direction |
Cartesian3 | 前方向。 |
up |
Cartesian3 | 上方向。 |
right |
Cartesian3 | 右方向。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.computeViewportTransformation(viewport, nearDepthRange, farDepthRange, result) → Matrix4
计算从归一化设备坐标变换到窗口坐标的 Matrix4 实例。
| Name | Type | Default | Description |
|---|---|---|---|
viewport |
Viewport |
{ x : 0.0, y : 0.0, width : 0.0, height : 0.0 }
|
optional 视口角点,如示例 1 所示。 |
nearDepthRange |
number |
0.0
|
optional 窗口坐标中的近平面距离。 |
farDepthRange |
number |
1.0
|
optional 窗口坐标中的远平面距离。 |
result |
Matrix4 | optional 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 使用显式视口和深度范围创建视口变换。
const m = Cesium.Matrix4.computeViewportTransformation({
x : 0.0,
y : 0.0,
width : 1024.0,
height : 768.0
}, 0.0, 1.0, new Cesium.Matrix4());
逐分量比较提供的矩阵,如果相等则返回
true,否则返回 false。
| Name | Type | Description |
|---|---|---|
left |
Matrix4 | optional 第一个矩阵。 |
right |
Matrix4 | optional 第二个矩阵。 |
Returns:
如果 left 和 right 相等则为
true,否则为 false。
Example:
// 比较两个 Matrix4 实例
// a = [10.0, 14.0, 18.0, 22.0]
// [11.0, 15.0, 19.0, 23.0]
// [12.0, 16.0, 20.0, 24.0]
// [13.0, 17.0, 21.0, 25.0]
// b = [10.0, 14.0, 18.0, 22.0]
// [11.0, 15.0, 19.0, 23.0]
// [12.0, 16.0, 20.0, 24.0]
// [13.0, 17.0, 21.0, 25.0]
if(Cesium.Matrix4.equals(a,b)) {
console.log("两个矩阵相等");
} else {
console.log("它们不相等");
}
// 在控制台打印 "两个矩阵相等"
逐分量比较提供的矩阵,如果它们在提供的 epsilon 范围内则返回
true,否则返回 false。
| Name | Type | Default | Description |
|---|---|---|---|
left |
Matrix4 | optional 第一个矩阵。 | |
right |
Matrix4 | optional 第二个矩阵。 | |
epsilon |
number |
0
|
optional 用于相等性测试的 epsilon。 |
Returns:
如果 left 和 right 在提供的 epsilon 范围内则为
true,否则为 false。
Example:
// 比较两个 Matrix4 实例
// a = [10.5, 14.5, 18.5, 22.5]
// [11.5, 15.5, 19.5, 23.5]
// [12.5, 16.5, 20.5, 24.5]
// [13.5, 17.5, 21.5, 25.5]
// b = [10.0, 14.0, 18.0, 22.0]
// [11.0, 15.0, 19.0, 23.0]
// [12.0, 16.0, 20.0, 24.0]
// [13.0, 17.0, 21.0, 25.0]
if(Cesium.Matrix4.equalsEpsilon(a,b,0.1)){
console.log("两个矩阵之间的差值小于 0.1");
} else {
console.log("两个矩阵之间的差值不小于 0.1");
}
// 在控制台打印 "两个矩阵之间的差值不小于 0.1"
static Cesium.Matrix4.fromArray(array, startingIndex, result) → Matrix4
从数组中 16 个连续元素创建 Matrix4。
| Name | Type | Default | Description |
|---|---|---|---|
array |
Array.<number> | 数组,其 16 个连续元素对应矩阵的位置。假设为列主序。 | |
startingIndex |
number |
0
|
optional 数组中第一个元素的偏移量,对应矩阵的第一列第一行位置。 |
result |
Matrix4 | optional 用于存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
Example:
// 创建 Matrix4:
// [1.0, 2.0, 3.0, 4.0]
// [1.0, 2.0, 3.0, 4.0]
// [1.0, 2.0, 3.0, 4.0]
// [1.0, 2.0, 3.0, 4.0]
const v = [1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0];
const m = Cesium.Matrix4.fromArray(v);
// 使用数组中的偏移量创建相同的 Matrix4
const v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0];
const m2 = Cesium.Matrix4.fromArray(v2, 2);
static Cesium.Matrix4.fromCamera(camera, result) → Matrix4
从 Camera 计算 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
camera |
Camera | 要使用的相机。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.fromColumnMajorArray(values, result) → Matrix4
从列主序数组计算 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
values |
Array.<number> | 列主序数组。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.fromRotation(rotation, result) → Matrix4
创建旋转矩阵。
| Name | Type | Description |
|---|---|---|
rotation |
Matrix3 | 旋转矩阵。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.fromRotationTranslation(rotation, translation, result) → Matrix4
从表示旋转的 Matrix3 实例和表示平移的 Cartesian3 实例计算 Matrix4 实例。
| Name | Type | Default | Description |
|---|---|---|---|
rotation |
Matrix3 | 矩阵的左上部分,表示旋转。 | |
translation |
Cartesian3 |
Cartesian3.ZERO
|
optional 矩阵的右上部分,表示平移。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.fromRowMajorArray(values, result) → Matrix4
从行主序数组计算 Matrix4 实例。
结果矩阵将按列主序存储。
| Name | Type | Description |
|---|---|---|
values |
Array.<number> | 行主序数组。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.fromScale(scale, result) → Matrix4
计算表示非均匀缩放的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
scale |
Cartesian3 | x、y 和 z 缩放因子。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
Example:
// 创建
// [7.0, 0.0, 0.0, 0.0]
// [0.0, 8.0, 0.0, 0.0]
// [0.0, 0.0, 9.0, 0.0]
// [0.0, 0.0, 0.0, 1.0]
const m = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));
static Cesium.Matrix4.fromTranslation(translation, result) → Matrix4
从表示平移的 Cartesian3 创建 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
translation |
Cartesian3 | 矩阵的右上部分,表示平移。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.fromTranslationQuaternionRotationScale(translation, rotation, scale, result) → Matrix4
从平移、旋转和缩放(TRS)表示计算 Matrix4 实例,其中旋转用四元数表示。
| Name | Type | Description |
|---|---|---|
translation |
Cartesian3 | 平移变换。 |
rotation |
Quaternion | 旋转变换。 |
scale |
Cartesian3 | 非均匀缩放变换。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
Example:
const result = Cesium.Matrix4.fromTranslationQuaternionRotationScale(
new Cesium.Cartesian3(1.0, 2.0, 3.0), // 平移
Cesium.Quaternion.IDENTITY, // 旋转
new Cesium.Cartesian3(7.0, 8.0, 9.0), // 缩放
result);
static Cesium.Matrix4.fromTranslationRotationScale(translationRotationScale, result) → Matrix4
从
TranslationRotationScale 实例创建 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
translationRotationScale |
TranslationRotationScale | 该实例。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.fromUniformScale(scale, result) → Matrix4
计算表示均匀缩放的 Matrix4 实例。
| Name | Type | Description |
|---|---|---|
scale |
number | 均匀缩放因子。 |
result |
Matrix4 | optional 用于存储结果的对象,如果未定义则创建新实例。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
Example:
// 创建
// [2.0, 0.0, 0.0, 0.0]
// [0.0, 2.0, 0.0, 0.0]
// [0.0, 0.0, 2.0, 0.0]
// [0.0, 0.0, 0.0, 1.0]
const m = Cesium.Matrix4.fromUniformScale(2.0);
static Cesium.Matrix4.getColumn(matrix, index, result) → Cartesian4
以 Cartesian4 实例的形式检索提供的列的矩阵副本。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
index |
number | 要检索的列的从零开始索引。 |
result |
Cartesian4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError : index 必须为 0、1、2 或 3。
Examples:
// 返回包含指定列值的 Cartesian4 实例
// m = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [18.0, 19.0, 20.0, 21.0]
// [22.0, 23.0, 24.0, 25.0]
// 示例 1: 创建 Cartesian 实例
const a = Cesium.Matrix4.getColumn(m, 2, new Cesium.Cartesian4());
// 示例 2: 为 Cartesian 实例设置值
const a = new Cesium.Cartesian4();
Cesium.Matrix4.getColumn(m, 2, a);
// a.x = 12.0; a.y = 16.0; a.z = 20.0; a.w = 24.0;
计算提供的行和列处的数组索引。
| Name | Type | Description |
|---|---|---|
row |
number | 行的从零开始索引。 |
column |
number | 列的从零开始索引。 |
Returns:
提供的行和列处的元素索引。
Throws:
-
DeveloperError : row 必须为 0、1、2 或 3。
-
DeveloperError : column 必须为 0、1、2 或 3。
Example:
const myMatrix = new Cesium.Matrix4();
const column1Row0Index = Cesium.Matrix4.getElementIndex(1, 0);
const column1Row0 = myMatrix[column1Row0Index];
myMatrix[column1Row0Index] = 10.0;
static Cesium.Matrix4.getMatrix3(matrix, result) → Matrix3
获取提供矩阵的左上角 3x3 矩阵。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
result |
Matrix3 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 从 Matrix4 实例返回 Matrix3 实例
// m = [10.0, 14.0, 18.0, 22.0]
// [11.0, 15.0, 19.0, 23.0]
// [12.0, 16.0, 20.0, 24.0]
// [13.0, 17.0, 21.0, 25.0]
const b = new Cesium.Matrix3();
Cesium.Matrix4.getMatrix3(m,b);
// b = [10.0, 14.0, 18.0]
// [11.0, 15.0, 19.0]
// [12.0, 16.0, 20.0]
计算最大缩放,假设矩阵为仿射变换。
最大缩放是左上角 3x3 矩阵中列向量的最大长度。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
Returns:
最大缩放。
static Cesium.Matrix4.getRotation(matrix, result) → Matrix3
提取旋转矩阵,假设矩阵为仿射变换。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
result |
Matrix3 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.getRow(matrix, index, result) → Cartesian4
以 Cartesian4 实例的形式检索提供的行的矩阵副本。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
index |
number | 要检索的行的从零开始索引。 |
result |
Cartesian4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError : index 必须为 0、1、2 或 3。
Examples:
// 返回包含指定行值的 Cartesian4 实例
// m = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [18.0, 19.0, 20.0, 21.0]
// [22.0, 23.0, 24.0, 25.0]
// 示例 1: 返回 Cartesian 实例
const a = Cesium.Matrix4.getRow(m, 2, new Cesium.Cartesian4());
// 示例 2: 为 Cartesian 实例设置值
const a = new Cesium.Cartesian4();
Cesium.Matrix4.getRow(m, 2, a);
// a.x = 18.0; a.y = 19.0; a.z = 20.0; a.w = 21.0;
static Cesium.Matrix4.getScale(matrix, result) → Cartesian3
提取非均匀缩放,假设矩阵为仿射变换。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
result |
Cartesian3 | 用于存储结果的对象。 |
Returns:
修改后的结果参数
See:
static Cesium.Matrix4.getTranslation(matrix, result) → Cartesian3
获取提供矩阵的平移部分,假设矩阵为仿射变换矩阵。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
result |
Cartesian3 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.inverse(matrix, result) → Matrix4
使用克莱姆法则计算提供矩阵的逆矩阵。
如果行列式为零,则矩阵不可逆,将抛出异常。
如果矩阵是proper rigid变换矩阵,则使用
Matrix4.inverseTransformation 求逆更高效。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要求逆的矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
RuntimeError : 矩阵不可逆,因为其行列式为零。
static Cesium.Matrix4.inverseTransformation(matrix, result) → Matrix4
计算提供矩阵的逆矩阵,假设它是proper rigid变换矩阵,
其中左上角 3x3 元素为旋转矩阵,
第四列的前三个元素为平移。
底行假定为 [0, 0, 0, 1]。
不验证矩阵是否符合该形式。
此方法比使用
Matrix4.inverse 计算通用 4x4
矩阵的逆更快。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要求逆的矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.inverseTranspose(matrix, result) → Matrix4
计算矩阵的逆矩阵的转置。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要转置并求逆的矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.multiply(left, right, result) → Matrix4
计算两个矩阵的乘积。
| Name | Type | Description |
|---|---|---|
left |
Matrix4 | 第一个矩阵。 |
right |
Matrix4 | 第二个矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.multiplyByMatrix3(matrix, rotation, result) → Matrix4
将变换矩阵(底行为
[0.0, 0.0, 0.0, 1.0])
与 3x3 旋转矩阵相乘。这是对
Matrix4.multiply(m, Matrix4.fromRotationTranslation(rotation), m); 的优化,减少了分配和算术运算。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 左侧的矩阵。 |
rotation |
Matrix3 | 右侧的 3x3 旋转矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 替代 Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromRotationTranslation(rotation), m);
Cesium.Matrix4.multiplyByMatrix3(m, rotation, m);
static Cesium.Matrix4.multiplyByPoint(matrix, cartesian, result) → Cartesian3
计算矩阵与
Cartesian3 的乘积。这等价于调用 Matrix4.multiplyByVector,
其中 Cartesian4 的 w 分量为 1,但返回 Cartesian3 而不是 Cartesian4。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
cartesian |
Cartesian3 | 点。 |
result |
Cartesian3 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
const p = new Cesium.Cartesian3(1.0, 2.0, 3.0);
const result = Cesium.Matrix4.multiplyByPoint(matrix, p, new Cesium.Cartesian3());
static Cesium.Matrix4.multiplyByPointAsVector(matrix, cartesian, result) → Cartesian3
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
cartesian |
Cartesian3 | 点。 |
result |
Cartesian3 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
const p = new Cesium.Cartesian3(1.0, 2.0, 3.0);
const result = Cesium.Matrix4.multiplyByPointAsVector(matrix, p, new Cesium.Cartesian3());
// 等价于
// Cartesian3 p = ...
// Cesium.Matrix4.multiplyByVector(matrix, new Cesium.Cartesian4(p.x, p.y, p.z, 0.0), result);
static Cesium.Matrix4.multiplyByScalar(matrix, scalar, result) → Matrix4
计算矩阵与标量的乘积。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
scalar |
number | 要乘的数。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 创建 Matrix4 实例,它是提供的 Matrix4 的缩放版本
// m = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [18.0, 19.0, 20.0, 21.0]
// [22.0, 23.0, 24.0, 25.0]
const a = Cesium.Matrix4.multiplyByScalar(m, -2, new Cesium.Matrix4());
// m 保持不变
// a = [-20.0, -22.0, -24.0, -26.0]
// [-28.0, -30.0, -32.0, -34.0]
// [-36.0, -38.0, -40.0, -42.0]
// [-44.0, -46.0, -48.0, -50.0]
static Cesium.Matrix4.multiplyByScale(matrix, scale, result) → Matrix4
将仿射变换矩阵(底行为
[0.0, 0.0, 0.0, 1.0])
与隐式非均匀缩放矩阵相乘。这是对
Matrix4.multiply(m, Matrix4.fromUniformScale(scale), m); 的优化,其中
m 必须是仿射矩阵。
此函数执行更少的分配和算术运算。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 左侧的仿射矩阵。 |
scale |
Cartesian3 | 右侧的非均匀缩放。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 替代 Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromScale(scale), m);
Cesium.Matrix4.multiplyByScale(m, scale, m);
See:
static Cesium.Matrix4.multiplyByTranslation(matrix, translation, result) → Matrix4
将变换矩阵(底行为
[0.0, 0.0, 0.0, 1.0])
与由 Cartesian3 定义的隐式平移矩阵相乘。这是对
Matrix4.multiply(m, Matrix4.fromTranslation(position), m); 的优化,减少了分配和算术运算。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 左侧的矩阵。 |
translation |
Cartesian3 | 右侧的平移。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 替代 Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromTranslation(position), m);
Cesium.Matrix4.multiplyByTranslation(m, position, m);
static Cesium.Matrix4.multiplyByUniformScale(matrix, scale, result) → Matrix4
计算矩阵与均匀缩放的乘积,如同缩放是一个缩放矩阵。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 左侧的矩阵。 |
scale |
number | 右侧的均匀缩放。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 替代 Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromUniformScale(scale), m);
Cesium.Matrix4.multiplyByUniformScale(m, scale, m);
See:
static Cesium.Matrix4.multiplyByVector(matrix, cartesian, result) → Cartesian4
计算矩阵与列向量的乘积。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
cartesian |
Cartesian4 | 向量。 |
result |
Cartesian4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.multiplyTransformation(left, right, result) → Matrix4
计算两个矩阵的乘积,假设矩阵为仿射变换矩阵,
其中左上角 3x3 元素为任意矩阵,
第四列的前三个元素为平移。
底行假定为 [0, 0, 0, 1]。
不验证矩阵是否符合该形式。
此方法比使用
Matrix4.multiply 计算通用 4x4
矩阵的乘积更快。
| Name | Type | Description |
|---|---|---|
left |
Matrix4 | 第一个矩阵。 |
right |
Matrix4 | 第二个矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
const m1 = new Cesium.Matrix4(1.0, 6.0, 7.0, 0.0, 2.0, 5.0, 8.0, 0.0, 3.0, 4.0, 9.0, 0.0, 0.0, 0.0, 0.0, 1.0);
const m2 = Cesium.Transforms.eastNorthUpToFixedFrame(new Cesium.Cartesian3(1.0, 1.0, 1.0));
const m3 = Cesium.Matrix4.multiplyTransformation(m1, m2, new Cesium.Matrix4());
static Cesium.Matrix4.negate(matrix, result) → Matrix4
计算提供矩阵的取反副本。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要取反的矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 创建新的 Matrix4 实例,它是 Matrix4 的取反
// m = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [18.0, 19.0, 20.0, 21.0]
// [22.0, 23.0, 24.0, 25.0]
const a = Cesium.Matrix4.negate(m, new Cesium.Matrix4());
// m 保持不变
// a = [-10.0, -11.0, -12.0, -13.0]
// [-14.0, -15.0, -16.0, -17.0]
// [-18.0, -19.0, -20.0, -21.0]
// [-22.0, -23.0, -24.0, -25.0]
将提供的实例存储到提供的数组中。
| Name | Type | Default | Description |
|---|---|---|---|
value |
Matrix4 | 要打包的值。 | |
array |
Array.<number> | 要打包到的数组。 | |
startingIndex |
number |
0
|
optional 开始打包元素的数组索引。 |
Returns:
被打包到的数组
将 Matrix4 数组展平为组件数组。组件
按列主序存储。
| Name | Type | Description |
|---|---|---|
array |
Array.<Matrix4> | 要打包的矩阵数组。 |
result |
Array.<number> |
optional
用于存储结果的数组。如果是类型化数组,则必须有 array.length * 16 个组件,否则会抛出 DeveloperError。如果是普通数组,则会被调整为 (array.length * 16) 个元素。 |
Returns:
打包后的数组。
static Cesium.Matrix4.setColumn(matrix, index, cartesian, result) → Matrix4
计算新矩阵,将提供矩阵中的指定列替换为提供的 Cartesian4 实例。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
index |
number | 要设置的列的从零开始索引。 |
cartesian |
Cartesian4 | 其值将分配给指定列的 Cartesian。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError : index 必须为 0、1、2 或 3。
Example:
// 从 Cartesian4 实例创建具有新列值的新 Matrix4 实例
// m = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [18.0, 19.0, 20.0, 21.0]
// [22.0, 23.0, 24.0, 25.0]
const a = Cesium.Matrix4.setColumn(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());
// m 保持不变
// a = [10.0, 11.0, 99.0, 13.0]
// [14.0, 15.0, 98.0, 17.0]
// [18.0, 19.0, 97.0, 21.0]
// [22.0, 23.0, 96.0, 25.0]
static Cesium.Matrix4.setRotation(matrix, rotation, result) → Matrix4
设置旋转,假设矩阵为仿射变换。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 矩阵。 |
rotation |
Matrix3 | 旋转矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.setRow(matrix, index, cartesian, result) → Matrix4
计算新矩阵,将提供矩阵中的指定行替换为提供的 Cartesian4 实例。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
index |
number | 要设置的行的从零开始索引。 |
cartesian |
Cartesian4 | 其值将分配给指定行的 Cartesian。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError : index 必须为 0、1、2 或 3。
Example:
// 从 Cartesian4 实例创建具有新行值的新 Matrix4 实例
// m = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [18.0, 19.0, 20.0, 21.0]
// [22.0, 23.0, 24.0, 25.0]
const a = Cesium.Matrix4.setRow(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());
// m 保持不变
// a = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [99.0, 98.0, 97.0, 96.0]
// [22.0, 23.0, 24.0, 25.0]
static Cesium.Matrix4.setScale(matrix, scale, result) → Matrix4
计算新矩阵,用提供的缩放替换缩放。
此方法假设矩阵为仿射变换。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
scale |
Cartesian3 | 替换提供矩阵缩放的缩放。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
See:
static Cesium.Matrix4.setTranslation(matrix, translation, result) → Matrix4
计算新矩阵,将提供矩阵最右列中的平移替换为提供的平移。
此方法假设矩阵为仿射变换。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
translation |
Cartesian3 | 替换提供矩阵平移的平移。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.setUniformScale(matrix, scale, result) → Matrix4
计算新矩阵,用提供的均匀缩放替换缩放。
此方法假设矩阵为仿射变换。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
scale |
number | 替换提供矩阵缩放的均匀缩放。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
See:
static Cesium.Matrix4.subtract(left, right, result) → Matrix4
计算两个矩阵的差。
| Name | Type | Description |
|---|---|---|
left |
Matrix4 | 第一个矩阵。 |
right |
Matrix4 | 第二个矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
从提供的 Matrix4 实例计算数组。
数组将按列主序排列。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
result |
Array.<number> | optional 用于存储结果的数组。 |
Returns:
修改后的数组参数,如果未提供则返回新数组实例。
Example:
// 从 Matrix4 实例创建数组
// m = [10.0, 14.0, 18.0, 22.0]
// [11.0, 15.0, 19.0, 23.0]
// [12.0, 16.0, 20.0, 24.0]
// [13.0, 17.0, 21.0, 25.0]
const a = Cesium.Matrix4.toArray(m);
// m 保持不变
// 创建 a = [10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0]
static Cesium.Matrix4.transpose(matrix, result) → Matrix4
计算提供矩阵的转置。
| Name | Type | Description |
|---|---|---|
matrix |
Matrix4 | 要转置的矩阵。 |
result |
Matrix4 | 用于存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// 返回 Matrix4 的转置
// m = [10.0, 11.0, 12.0, 13.0]
// [14.0, 15.0, 16.0, 17.0]
// [18.0, 19.0, 20.0, 21.0]
// [22.0, 23.0, 24.0, 25.0]
const a = Cesium.Matrix4.transpose(m, new Cesium.Matrix4());
// m 保持不变
// a = [10.0, 14.0, 18.0, 22.0]
// [11.0, 15.0, 19.0, 23.0]
// [12.0, 16.0, 20.0, 24.0]
// [13.0, 17.0, 21.0, 25.0]
static Cesium.Matrix4.unpack(array, startingIndex, result) → Matrix4
从打包数组中检索实例。
| Name | Type | Default | Description |
|---|---|---|---|
array |
Array.<number> | 打包的数组。 | |
startingIndex |
number |
0
|
optional 要解包元素的起始索引。 |
result |
Matrix4 | optional 用于存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回新的 Matrix4 实例。
static Cesium.Matrix4.unpackArray(array, result) → Array.<Matrix4>
将列主序矩阵组件数组解包为 Matrix4 数组。
| Name | Type | Description |
|---|---|---|
array |
Array.<number> | 要解包的组件数组。 |
result |
Array.<Matrix4> | optional 用于存储结果的数组。 |
Returns:
解包后的数组。
