new Cesium.Matrix4(column0Row0, column1Row0, column2Row0, column3Row0, column0Row1, column1Row1, column2Row1, column3Row1, column0Row2, column1Row2, column2Row2, column3Row2, column0Row3, column1Row3, column2Row3, column3Row3)
一个4x4矩阵,可作为列主序数组进行索引。
构造函数参数按行的主要顺序排列,以提高代码的可读性。
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.fromColumnMajorArray
- Matrix4.fromRowMajorArray
- Matrix4.fromRotationTranslation
- Matrix4.fromTranslationRotationScale
- Matrix4.fromTranslationQuaternionRotationScale
- Matrix4.fromTranslation
- Matrix4.fromScale
- Matrix4.fromUniformScale
- Matrix4.fromCamera
- Matrix4.computePerspectiveFieldOfView
- Matrix4.computeOrthographicOffCenter
- Matrix4.computePerspectiveOffCenter
- Matrix4.computeInfinitePerspectiveOffCenter
- Matrix4.computeViewportTransformation
- Matrix4.computeView
- Matrix2
- Matrix3
- Packable
See:
Members
获取集合中的项数。
第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行的Matrix4索引。
static constant Cesium.Matrix4.IDENTITY : Matrix4
初始化为标识矩阵的不可变Matrix4实例。
用于将对象打包到数组中的元素数。
static constant Cesium.Matrix4.ZERO : 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
。将此矩阵与提供的矩阵组件进行比较并返回
true
如果它们在规定的epsilon范围内,
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实例(如果未提供)。(如果矩阵未定义,则返回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
从一个标准化的窗口转换成坐标X4。
Name | Type | Default | Description |
---|---|---|---|
viewport |
Object |
{ 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:
// Create viewport transformation using an explicit viewport and depth range.
var 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:
如果左右相等,则为
true
,否则为false
。Example:
//compares two Matrix4 instances
// 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("Both matrices are equal");
} else {
console.log("They are not equal");
}
//Prints "Both matrices are equal" on the console
将提供的矩阵按组件方式进行比较并返回
true
如果它们在规定的epsilon范围内,
false
否则。Name | Type | Default | Description |
---|---|---|---|
left |
Matrix4 | optional 第一个矩阵。 | |
right |
Matrix4 | optional 第二个矩阵。 | |
epsilon |
Number |
0
|
optional 用于相等性测试的epsilon。 |
Returns:
true
如果左、右在规定的epsilon范围内,则为false
。Example:
//compares two Matrix4 instances
// 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("Difference between both the matrices is less than 0.1");
} else {
console.log("Difference between both the matrices is not less than 0.1");
}
//Prints "Difference between both the matrices is not less than 0.1" on the console
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:
// Create the 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]
var 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];
var m = Cesium.Matrix4.fromArray(v);
// Create same Matrix4 with using an offset into an array
var 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];
var m2 = Cesium.Matrix4.fromArray(v2, 2);
static Cesium.Matrix4.fromCamera(camera, result) → Matrix4
从摄影机计算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.fromRotationTranslation(rotation, translation, result) → Matrix4
从表示旋转的Matrix3计算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:
// Creates
// [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]
var 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:
var result = Cesium.Matrix4.fromTranslationQuaternionRotationScale(
new Cesium.Cartesian3(1.0, 2.0, 3.0), // translation
Cesium.Quaternion.IDENTITY, // rotation
new Cesium.Cartesian3(7.0, 8.0, 9.0), // scale
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:
// Creates
// [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]
var 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 :索引必须为0、1、2或3。
Examples:
//returns a Cartesian4 instance with values from the specified column
// 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]
//Example 1: Creates an instance of Cartesian
var a = Cesium.Matrix4.getColumn(m, 2, new Cesium.Cartesian4());
//Example 2: Sets values for Cartesian instance
var 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 :行必须为0、1、2或3。
-
DeveloperError :列必须为0、1、2或3。
Example:
var myMatrix = new Cesium.Matrix4();
var column1Row0Index = Cesium.Matrix4.getElementIndex(1, 0);
var column1Row0 = myMatrix[column1Row0Index];
myMatrix[column1Row0Index] = 10.0;
static Cesium.Matrix4.getMatrix3(matrix, result) → Matrix3
获取所提供矩阵的左上3x3旋转矩阵,假设该矩阵是仿射变换矩阵。
Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
result |
Matrix3 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// returns a Matrix3 instance from a Matrix4 instance
// 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]
var 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.getRow(matrix, index, result) → Cartesian4
以Cartesian4实例检索所提供索引处的矩阵行的副本。
Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
index |
Number | 要检索的行的从零开始的索引。 |
result |
Cartesian4 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError :索引必须为0、1、2或3。
Examples:
//returns a Cartesian4 instance with values from the specified column
// 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]
//Example 1: Returns an instance of Cartesian
var a = Cesium.Matrix4.getRow(m, 2, new Cesium.Cartesian4());
//Example 2: Sets values for a Cartesian instance
var 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:
修改后的结果参数
static Cesium.Matrix4.getTranslation(matrix, result) → Cartesian3
获取所提供矩阵的平移部分,假定该矩阵是仿射变换矩阵。
Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
result |
Cartesian3 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
static Cesium.Matrix4.inverse(matrix, result) → Matrix4
使用Cramers规则计算所提供矩阵的逆。
如果行列式为零,则无法反转矩阵,并引发异常。
如果矩阵是仿射变换矩阵,则效率更高
用
Matrix4.inverseTransformation
倒过来。Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 要反转的矩阵。 |
result |
Matrix4 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
RuntimeError :矩阵不可逆,因为它的确定项为零。
static Cesium.Matrix4.inverseTransformation(matrix, result) → Matrix4
计算所提供矩阵的逆矩阵
仿射变换矩阵,其中左上3x3个元素
是一个旋转矩阵,上面三个元素在第四个元素中
列是翻译。下面一行假定为[0,0,0,1]。
未验证矩阵的形式是否正确。
这种方法比一般4x4的求逆快
矩阵使用
Matrix4.inverse
。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:
// Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromRotationTranslation(rotation), m);
Cesium.Matrix4.multiplyByMatrix3(m, rotation, m);
static Cesium.Matrix4.multiplyByPoint(matrix, cartesian, result) → Cartesian3
Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 矩阵。 |
cartesian |
Cartesian3 | 重点。 |
result |
Cartesian3 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
var p = new Cesium.Cartesian3(1.0, 2.0, 3.0);
var 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:
var p = new Cesium.Cartesian3(1.0, 2.0, 3.0);
var result = Cesium.Matrix4.multiplyByPointAsVector(matrix, p, new Cesium.Cartesian3());
// A shortcut for
// 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:
//create a Matrix4 instance which is a scaled version of the supplied 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]
var a = Cesium.Matrix4.multiplyByScalar(m, -2, new Cesium.Matrix4());
// m remains the same
// 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
乘以仿射变换
m
矩阵(底行为[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:
// Instead of 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:
// Instead of Cesium.Matrix4.multiply(m, Cesium.Matrix4.fromTranslation(position), m);
Cesium.Matrix4.multiplyByTranslation(m, position, m);
static Cesium.Matrix4.multiplyByUniformScale(matrix, scale, result) → Matrix4
乘以仿射变换
m
矩阵(底行为[0.0, 0.0, 0.0, 1.0]
)
通过隐式一致尺度矩阵。这是一个优化
Matrix4.multiply(m, Matrix4.fromUniformScale(scale), m);
,在哪里
m必须是仿射矩阵。
此函数执行较少的分配和算术运算。Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 左边的仿射矩阵。 |
scale |
Number | 右手边的统一刻度。 |
result |
Matrix4 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
// Instead of 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]。
未验证矩阵的形式是否正确。
这种方法比计算一般4x4的乘积要快
使用
Matrix4.multiply
的矩阵。Name | Type | Description |
---|---|---|
left |
Matrix4 | 第一个矩阵。 |
right |
Matrix4 | 第二个矩阵。 |
result |
Matrix4 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Example:
var 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);
var m2 = Cesium.Transforms.eastNorthUpToFixedFrame(new Cesium.Cartesian3(1.0, 1.0, 1.0));
var 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:
//create a new Matrix4 instance which is a negation of a 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]
var a = Cesium.Matrix4.negate(m, new Cesium.Matrix4());
// m remains the same
// 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:
被压缩到的数组
static Cesium.Matrix4.setColumn(matrix, index, cartesian, result) → Matrix4
计算一个新矩阵,该矩阵用所提供的Cartesian4实例替换所提供矩阵中的指定列。
Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
index |
Number | 要设置的列的从零开始的索引。 |
cartesian |
Cartesian4 | 其值将分配给指定列的笛卡尔坐标。 |
result |
Matrix4 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError :索引必须为0、1、2或3。
Example:
//creates a new Matrix4 instance with new column values from the Cartesian4 instance
// 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]
var a = Cesium.Matrix4.setColumn(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());
// m remains the same
// 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.setRow(matrix, index, cartesian, result) → Matrix4
计算一个新矩阵,该矩阵用所提供的Cartesian4实例替换所提供矩阵中的指定行。
Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
index |
Number | 要设置的行的从零开始的索引。 |
cartesian |
Cartesian4 | 其值将分配给指定行的笛卡尔坐标。 |
result |
Matrix4 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
Throws:
-
DeveloperError :索引必须为0、1、2或3。
Example:
//create a new Matrix4 instance with new row values from the Cartesian4 instance
// 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]
var a = Cesium.Matrix4.setRow(m, 2, new Cesium.Cartesian4(99.0, 98.0, 97.0, 96.0), new Cesium.Matrix4());
// m remains the same
// 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:
修改后的结果参数。
static Cesium.Matrix4.setTranslation(matrix, translation, result) → Matrix4
计算一个新矩阵,该矩阵替换所提供的
矩阵和提供的翻译。这假设矩阵是仿射变换
Name | Type | Description |
---|---|---|
matrix |
Matrix4 | 要使用的矩阵。 |
translation |
Cartesian3 | 替换所提供矩阵的转换。 |
result |
Matrix4 | 要存储结果的对象。 |
Returns:
修改后的结果参数。
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:
//create an array from an instance of 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]
var a = Cesium.Matrix4.toArray(m);
// m remains the same
//creates 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:
//returns transpose of a 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]
var a = Cesium.Matrix4.transpose(m, new Cesium.Matrix4());
// m remains the same
// 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实例(如果未提供)。