Matrix3
是表示3x3矩阵的类,它用于旋转、缩放和变换对象的几何空间。
Matrix3()
:创建一个新的3x3矩阵,该矩阵的所有元素都初始化为零。var matrix = new Cesium.Matrix3();
Matrix3.fromRowMajorArray(values)
:使用给定的按行主序排列的数组中的值创建一个新的3x3矩阵。var values = [
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
];
var matrix = Cesium.Matrix3.fromRowMajorArray(values);
COLUMN0ROW0
、 COLUMN0ROW1
、 COLUMN0ROW2
、 COLUMN1ROW0
、 COLUMN1ROW1
、 COLUMN1ROW2
、 COLUMN2ROW0
、 COLUMN2ROW1
和COLUMN2ROW2
:一个具有九个元素的数组,该数组表示3x3矩阵。var matrix = new Cesium.Matrix3();
var column0Row0 = matrix.COLUMN0ROW0; // 0
var column1Row1 = matrix.COLUMN1ROW1; // 0
matrix.COLUMN2ROW0 = 1.0;
clone(matrix, result)
:返回一个新的矩阵,该矩阵与 matrix
相同。var m1 = new Cesium.Matrix3();
var m2 = Cesium.Matrix3.clone(m1);
equals(left, right)
:检查 left
和 right
是否相等。var m1 = new Cesium.Matrix3();
var m2 = new Cesium.Matrix3();
var equals = Cesium.Matrix3.equals(m1, m2); // true
fromArray(array, startingIndex, result)
:从数组中指定的索引创建一个新的矩阵。var array = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0];
var matrix = Cesium.Matrix3.fromArray(array, 0);
fromColumnMajorArray(values, result)
:从按列主序排列的数组中的值创建一个新的3x3矩阵。var values = [
1.0, 4.0, 7.0,
2.0, 5.0, 8.0,
3.0, 6.0, 9.0
];
var matrix = Cesium.Matrix3.fromColumnMajorArray(values);
fromCrossProduct(theVector, result)
:计算向量的叉乘矩阵。var vector = new Cesium.Cartesian3(1.0, 1.0, 1.0);
var matrix = Cesium.Matrix3.fromCrossProduct(vector);
fromQuaternion(quaternion, result)
:计算旋转矩阵。var quaternion = new Cesium.Quaternion();
var matrix = Cesium.Matrix3.fromQuaternion(quaternion);
fromRotationX(angle, result)
:计算绕x轴旋转给定角度的矩阵。var angle = Cesium.Math.toRadians(45);
var matrix = Cesium.Matrix3.fromRotationX(angle);
fromRotationY(angle, result)
:计算绕y轴旋转给定角度的矩阵。var angle = Cesium.Math.toRadians(45);
var matrix = Cesium.Matrix3.fromRotationY(angle);
fromRotationZ(angle, result)
:计算绕z轴旋转给定角度的矩阵。var angle = Cesium.Math.toRadians(45);
var matrix = Cesium.Matrix3.fromRotationZ(angle);
fromRowMajorArray(values, result)
:使用给定的按行主序排列的数组中的值创建一个新的3x3矩阵。var values = [
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
];
var matrix = Cesium.Matrix3.fromRowMajorArray(values);
fromScale(scale, result)
:计算缩放矩阵。var scale = new Cesium.Cartesian3(2.0, 2.0, 2.0);
var matrix = Cesium.Matrix3.fromScale(scale);
fromUniformScale(scale, result)
:计算等比缩放矩阵。var scale = 2.0;
var matrix = Cesium.Matrix3.fromUniformScale(scale);
getIndex(row, column)
:返回指定的行列位置的矩阵元素。var matrix = new Cesium.Matrix3();
var element = matrix.getIndex(1, 2); // 0
getRow(matrix, index, result)
:将矩阵中的行复制到提供的结果对象中。var matrix = new Cesium.Matrix3();
var row = new Cesium.Cartesian3();
Cesium.Matrix3.getRow(matrix, 1, row);
multiply(left, right, result)
:计算两个矩阵的乘积。var m1 = new Cesium.Matrix3();
var m2 = new Cesium.Matrix3();
var matrix = Cesium.Matrix3.multiply(m1, m2);
multiplyByScalar(matrix, scalar, result)
:计算矩阵和标量的积。var matrix = new Cesium.Matrix3();
var scalar = 2.0;
var matrix = Cesium.Matrix3.multiplyByScalar(matrix, scalar);
multiplyByVector(matrix, cartesian, result)
:计算矩阵和点的乘积。var matrix = new Cesium.Matrix3();
var cartesian = new Cesium.Cartesian3(2.0, 3.0, 4.0);
var point = Cesium.Matrix3.multiplyByVector(matrix, cartesian);
setColumn(matrix, index, cartesian, result)
:设置矩阵中指定列的值。var matrix = new Cesium.Matrix3();
var cartesian = new Cesium.Cartesian3(2.0, 3.0, 4.0);
Cesium.Matrix3.setColumn(matrix, 1, cartesian);
setIndex(row, column, value)
:设置矩阵元素的值。var matrix = new Cesium.Matrix3();
matrix.setIndex(2, 2, 1.0);
transpose(matrix, result)
:计算矩阵的转置。var matrix = new Cesium.Matrix3();
var transposeMatrix = Cesium.Matrix3.transpose(matrix);
以下示例演示如何创建Matrix3、计算Matrix3的转置以及Matrix3与Cartesian3的乘法。
var matrix = new Cesium.Matrix3(
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
);
var transpose = Cesium.Matrix3.transpose(matrix);
var cartesian = new Cesium.Cartesian3(1.0, 2.0, 3.0);
var result = Cesium.Matrix3.multiplyByVector(matrix, cartesian);