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

第 1 列第 1 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN1ROW2 : number

第 1 列第 2 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN1ROW3 : number

第 1 列第 3 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN2ROW0 : number

第 2 列第 0 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN2ROW1 : number

第 2 列第 1 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN2ROW2 : number

第 2 列第 2 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN2ROW3 : number

第 2 列第 3 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN3ROW0 : number

第 3 列第 0 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN3ROW1 : number

第 3 列第 1 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN3ROW2 : number

第 3 列第 2 行的 Matrix4 索引。

static constant Cesium.Matrix4.COLUMN3ROW3 : number

第 3 列第 3 行的 Matrix4 索引。

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 右边 matrix.
Returns:
true,否则为false

equalsEpsilon(right, epsilon)boolean

将此矩阵与提供的矩阵进行分量比较,并返回 true,如果它们位于提供的 epsilon 内, 否则 false
Name Type Default Description
right Matrix4 optional 右边 matrix.
epsilon number 0 optional 用来检验等式。
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 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 第一个matrix.
right Matrix4 optional 第二个 matrix.
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 第一个matrix.
right Matrix4 optional 第二个 matrix.
epsilon number 0 optional 用来检验等式。
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]

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 计算 Matrix4 实例 和一个表示翻译的笛卡尔 3。
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

使用 Cramers 规则计算所提供矩阵的逆矩阵。 如果行列式为零,则矩阵不能反转,并引发异常。 如果矩阵是适当的刚体变换,则效率更高 将其与 Matrix4.inverseTransformation 进行反转。
Name Type Description
matrix Matrix4 要反转的矩阵。
result Matrix4 要在其上存储结果的对象。
Returns:
修改后的结果参数。
Throws:
  • RuntimeError : matrix is not invertible because its determinate is zero.

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 Matrix2 左侧的矩阵。
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 替换为 Cartesian4其中 w 分量为零。
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]。 未验证矩阵的格式是否正确。 此方法比一般 4x4 计算乘积更快 使用 Matrix4.multiply 的矩阵。
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 笛卡尔 其值将被分配给指定列的笛卡尔。
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 笛卡尔 其值将被分配给指定行的笛卡尔。
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 替换所提供矩阵的 scale 的统一小数位数。
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 要在其中存储结果的数组。
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:
未打包的数组。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.