Matrix4

A 4x4 matrix, indexable as a column-major order array. Constructor parameters are in row-major order for code readability.

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 行的值。
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

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

toString()string

创建一个表示此 Matrix 的字符串,其中每一行 单独占一行,格式为 '(column0, column1, column2, column3)'。
Returns:
表示所提供 Matrix 的字符串,其中每一行单独占一行,格式为 '(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)

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 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:
// 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 如果 left 和 right 相等,否则为 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

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

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

从一个 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:
// 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 要使用的矩阵。
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 : matrix 因其 determinate 为零而不可逆。

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 实例创建一个 Array。 该数组将为列主序。
Name Type Description
matrix Matrix4 要使用的矩阵。
result Array.<number> optional 用于存储结果的 Array。
Returns:
修改后的 Array 参数;如果未提供,则为新的 Array 实例。
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 论坛 上向社区和团队提问。