Matrix4

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 的值。
See:

Members

获取集合中的项目数量。

static constant Cesium.Matrix4.COLUMN0ROW0 : number

Matrix4 中列 0,行 0 的索引。

static constant Cesium.Matrix4.COLUMN0ROW1 : number

Matrix4 中列 0,行 1 的索引。

static constant Cesium.Matrix4.COLUMN0ROW2 : number

Matrix4 中列 0,行 2 的索引。

static constant Cesium.Matrix4.COLUMN0ROW3 : number

Matrix4中第0列第3行的索引。

static constant Cesium.Matrix4.COLUMN1ROW0 : number

Matrix4中第1列第0行的索引。

static constant Cesium.Matrix4.COLUMN1ROW1 : number

Matrix4中第1列第1行的索引。

static constant Cesium.Matrix4.COLUMN1ROW2 : number

Matrix4中第1列第2行的索引。

static constant Cesium.Matrix4.COLUMN1ROW3 : number

Matrix4中第1列第3行的索引。

static constant Cesium.Matrix4.COLUMN2ROW0 : number

Matrix4中第2列第0行的索引。

static constant Cesium.Matrix4.COLUMN2ROW1 : number

Matrix4中第2列第1行的索引。

static constant Cesium.Matrix4.COLUMN2ROW2 : number

Matrix4中第2列第2行的索引。

static constant Cesium.Matrix4.COLUMN2ROW3 : number

Matrix4中第2列第3行的索引。

static constant Cesium.Matrix4.COLUMN3ROW0 : number

Matrix4中第3列第0行的索引。

static constant Cesium.Matrix4.COLUMN3ROW1 : number

Matrix4中第3列第1行的索引。

static constant Cesium.Matrix4.COLUMN3ROW2 : number

Matrix4中第3列第2行的索引。

static constant Cesium.Matrix4.COLUMN3ROW3 : number

Matrix4中第3列第3行的索引。

static constant Cesium.Matrix4.IDENTITY : Matrix4

一个初始化为单位矩阵的不可变 Matrix4 实例。

static Cesium.Matrix4.packedLength : number

用于将对象打包到数组中的元素数量。

static constant Cesium.Matrix4.ZERO : Matrix4

一个初始化为零矩阵的不可变 Matrix4 实例。

Methods

复制提供的Matrix4实例。
Name Type Description
result Matrix4 optional 存储结果的对象.
Returns:
修改后的结果参数,或者如果未提供,则返回一个新的Matrix4实例。

equals(right) → boolean

将此矩阵与提供的矩阵逐个分量进行比较,并返回 如果相等则为 true,否则为 false
Name Type Description
right Matrix4 optional 右侧矩阵。
Returns:
如果相等则为 true,否则为 false

equalsEpsilon(right, epsilon) → boolean

将此矩阵与提供的矩阵逐个分量进行比较,并返回 true 如果它们在提供的 epsilon 范围内, false 否则。
Name Type Default Description
right Matrix4 optional 右侧矩阵。
epsilon number 0 optional 用于相等测试的epsilon值。
Returns:
如果它们在提供的 epsilon 范围内,则为 true,否则为 false

toString() → string

计算一个字符串,表示该矩阵,每一行在单独一行,并且格式为 '(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:

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 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.
const m = Cesium.Matrix4.computeViewportTransformation({
    x : 0.0,
    y : 0.0,
    width : 1024.0,
    height : 768.0
}, 0.0, 1.0, new Cesium.Matrix4());

static Cesium.Matrix4.equals(left, right) → boolean

分别比较提供的矩阵并返回 如果相等则为 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

static Cesium.Matrix4.equalsEpsilon(left, right, epsilon) → boolean

分别比较提供的矩阵并返回 true 如果它们在提供的 epsilon 范围内, false 否则。
Name Type Default Description
left Matrix4 optional 第一个矩阵。
right Matrix4 optional 第二个矩阵。
epsilon number 0 optional 用于相等性测试的 epsilon。
Returns:
如果左侧和右侧在提供的 epsilon 范围内,则返回 true,否则返回 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]

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);

// Create same Matrix4 with using an offset into an array
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

从相机计算一个 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:
// 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]
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 实例。
See:

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), // 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]
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:
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
const a = Cesium.Matrix4.getColumn(m, 2, new Cesium.Cartesian4());
//Example 2: Sets values for Cartesian instance
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;

static Cesium.Matrix4.getElementIndex(row, column) → number

计算提供的行和列对应元素的数组索引。
Name Type Description
row number 行的零基索引。
column number 列的零基索引。
Returns:
提供的行和列对应元素的索引。
Throws:
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 The matrix to use.
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]

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]

static Cesium.Matrix4.getMaximumScale(matrix) → number

计算最大缩放,假设矩阵是一个仿射变换。 最大缩放是左上角 3x3 矩阵中列向量的最大长度。
Name Type Description
matrix Matrix4 矩阵。
Returns:
最大缩放。

static Cesium.Matrix4.getRotation(matrix, result) → Matrix3

提取旋转矩阵,假设矩阵是一个仿射变换。
Name Type Description
matrix Matrix4 矩阵。
result Matrix3 存储结果的对象。
Returns:
修改后的结果参数
See:

static Cesium.Matrix4.getRow(matrix, index, result) → Cartesian4

以 Cartesian4 实例形式检索提供索引的矩阵行的副本。
Name Type Description
matrix Matrix4 要使用的矩阵。
index number 要检索的行的零基索引。
result Cartesian4 存储结果的对象。
Returns:
修改后的结果参数
Throws:
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
const a = Cesium.Matrix4.getRow(m, 2, new Cesium.Cartesian4());
//Example 2: Sets values for a Cartesian instance
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

使用克拉默法则计算提供矩阵的逆。 如果行列式为零,则矩阵无法逆转,此时会抛出异常。 如果矩阵是一个适当的刚体变换,则使用 Matrix4.inverseTransformation 进行反转更有效。
Name Type Description
matrix Matrix4 要逆转的矩阵。
result Matrix4 存储结果的对象。
Returns:
修改后的结果参数
Throws:
  • RuntimeError : 矩阵不可逆,因为其行列式为零。

static Cesium.Matrix4.inverseTransformation(matrix, result) → Matrix4

计算提供矩阵的逆,假设它是一个适当的刚体矩阵, 其中左上 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:
// 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

计算一个矩阵与 Cartesian3 的乘积。这相当于调用 Matrix4.multiplyByVector 使用 w 组件为 1 的 Cartesian4,但返回 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

计算一个矩阵与 Cartesian3 的乘积。这相当于调用 Matrix4.multiplyByVector 使用 w 组件为零的 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.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]

const 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

将一个仿射变换矩阵(底行为 [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

计算一个矩阵与均匀缩放的乘积,就像缩放是一个缩放矩阵一样。
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]。 该矩阵未验证为正确格式。 此方法比使用 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:
//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]

const 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]

static Cesium.Matrix4.pack(value, array, startingIndex) → Array.<number>

将提供的实例存储到提供的数组中.
Name Type Default Description
value Matrix4 要打包的值.
array Array.<number> 要打包到的数组.
startingIndex number 0 optional 开始打包元素的数组索引.
Returns:
被打包成的数组

static Cesium.Matrix4.packArray(array, result) → Array.<number>

将一个 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:
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]

const 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.setRotation(matrix, rotation, result) → Matrix4

设置旋转,假设矩阵是一个仿射变换。
Name Type Description
matrix Matrix4 矩阵。
rotation Matrix3 旋转矩阵。
result Matrix4 存储结果的对象。
Returns:
修改后的结果参数
See:

static Cesium.Matrix4.setRow(matrix, index, cartesian, result) → Matrix4

计算一个新矩阵,该矩阵用提供的 Cartesian4 实例替换提供矩阵中指定行。
Name Type Description
matrix Matrix4 要使用的矩阵。
index number 要设置的行的零基索引。
cartesian Cartesian4 将其值分配给指定行的 Cartesian。
result Matrix4 存储结果的对象。
Returns:
修改后的结果参数
Throws:
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]

const 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:
修改后的结果参数
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:
修改后的结果参数

static Cesium.Matrix4.toArray(matrix, result) → Array.<number>

从提供的 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]
const 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]

const 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 实例。

static Cesium.Matrix4.unpackArray(array, result) → Array.<Matrix4>

将列主序矩阵组件数组解包为 Matrix4 数组。
Name Type Description
array Array.<number> 要解包的组件数组。
result Array.<Matrix4> optional 存储结果的数组。
Returns:
解包后的数组。
需要帮助?获得答案的最快方法是来自社区和团队 Cesium Forum.