new Matrix2(column0Row0, column1Row0, column0Row1, column1Row1)
A 2x2 matrix, indexable as a column-major order array.
Constructor parameters are in row-major order for code readability.
| Name | Type | Default | Description |
|---|---|---|---|
column0Row0 |
Number |
0.0
|
optional The value for column 0, row 0. |
column1Row0 |
Number |
0.0
|
optional The value for column 1, row 0. |
column0Row1 |
Number |
0.0
|
optional The value for column 0, row 1. |
column1Row1 |
Number |
0.0
|
optional The value for column 1, row 1. |
- Matrix2.fromColumnMajor
- Matrix2.fromRowMajorArray
- Matrix2.fromScale
- Matrix2.fromUniformScale
- Matrix3
- Matrix4
See:
Source:
Core/Matrix2.js, line 34
Members
-
staticconstantMatrix2.COLUMN0ROW0 :Number
-
The index into Matrix2 for column 0, row 0.
Example:
var matrix = new Cesium.Matrix2(); matrix[Matrix2.COLUMN0ROW0] = 5.0; // set column 0, row 0 to 5.0Source: Core/Matrix2.js, line 702 -
staticconstantMatrix2.COLUMN0ROW1 :Number
-
The index into Matrix2 for column 0, row 1.
Example:
var matrix = new Cesium.Matrix2(); matrix[Matrix2.COLUMN0ROW1] = 5.0; // set column 0, row 1 to 5.0Source: Core/Matrix2.js, line 714 -
staticconstantMatrix2.COLUMN1ROW0 :Number
-
The index into Matrix2 for column 1, row 0.
Example:
var matrix = new Cesium.Matrix2(); matrix[Matrix2.COLUMN1ROW0] = 5.0; // set column 1, row 0 to 5.0Source: Core/Matrix2.js, line 726 -
staticconstantMatrix2.COLUMN1ROW1 :Number
-
The index into Matrix2 for column 1, row 1.
Example:
var matrix = new Cesium.Matrix2(); matrix[Matrix2.COLUMN1ROW1] = 5.0; // set column 1, row 1 to 5.0Source: Core/Matrix2.js, line 738 -
staticconstantMatrix2.IDENTITY :Matrix2
-
An immutable Matrix2 instance initialized to the identity matrix.Source: Core/Matrix2.js, line 689
Methods
-
clone(result) → Matrix2
-
Duplicates the provided Matrix2 instance.
Name Type Description resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Source: Core/Matrix2.js, line 746 -
equals(right) → Boolean
-
Compares this matrix to the provided matrix componentwise and returns
trueif they are equal,falseotherwise.Name Type Description rightMatrix2 optional The right hand side matrix. Returns:
trueif they are equal,falseotherwise.Source: Core/Matrix2.js, line 757 -
equalsEpsilon(right, epsilon) → Boolean
-
Compares this matrix to the provided matrix componentwise and returns
trueif they are within the provided epsilon,falseotherwise.Name Type Description rightMatrix2 optional The right hand side matrix. epsilonNumber The epsilon to use for equality testing. Returns:
trueif they are within the provided epsilon,falseotherwise.Source: Core/Matrix2.js, line 770 -
toString() → String
-
Creates a string representing this Matrix with each row being on a separate line and in the format '(column0, column1)'.
Returns:
A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1)'.Source: Core/Matrix2.js, line 780 -
staticMatrix2.abs(matrix, result) → Matrix2
-
Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
Name Type Description matrixMatrix2 The matrix with signed elements. resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Source: Core/Matrix2.js, line 620 -
staticMatrix2.clone(matrix, result) → Matrix2
-
Duplicates a Matrix2 instance.
Name Type Description matrixMatrix2 The matrix to duplicate. resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided. (Returns undefined if matrix is undefined)Source: Core/Matrix2.js, line 48 -
staticMatrix2.equals(left, right) → Boolean
-
Compares the provided matrices componentwise and returns
trueif they are equal,falseotherwise.Name Type Description leftMatrix2 optional The first matrix. rightMatrix2 optional The second matrix. Returns:
trueif left and right are equal,falseotherwise.Source: Core/Matrix2.js, line 647 -
staticMatrix2.equalsEpsilon(left, right, epsilon) → Boolean
-
Compares the provided matrices componentwise and returns
trueif they are within the provided epsilon,falseotherwise.Name Type Description leftMatrix2 optional The first matrix. rightMatrix2 optional The second matrix. epsilonNumber The epsilon to use for equality testing. Returns:
trueif left and right are within the provided epsilon,falseotherwise.Source: Core/Matrix2.js, line 667 -
staticMatrix2.fromArray(array, startingIndex, result) → Matrix2
-
Creates a Matrix2 from 4 consecutive elements in an array.
Name Type Default Description arrayArray.<Number> The array whose 4 consecutive elements correspond to the positions of the matrix. Assumes column-major order. startingIndexNumber 0optional The offset into the array of the first element, which corresponds to first column first row position in the matrix. resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Example:
// Create the Matrix2: // [1.0, 2.0] // [1.0, 2.0] var v = [1.0, 1.0, 2.0, 2.0]; var m = Cesium.Matrix2.fromArray(v); // Create same Matrix2 with using an offset into an array var v2 = [0.0, 0.0, 1.0, 1.0, 2.0, 2.0]; var m2 = Cesium.Matrix2.fromArray(v2, 2);Source: Core/Matrix2.js, line 83 -
staticMatrix2.fromColumnMajorArray(values, result)
-
Creates a Matrix2 instance from a column-major order array.
Name Type Description valuesArray.<Number> The column-major order array. resultMatrix2 optional The object in which the result will be stored, if undefined a new instance will be created. Returns:
The modified result parameter, or a new Matrix2 instance if one was not provided.Source: Core/Matrix2.js, line 110 -
staticMatrix2.fromRotation(angle, result)
-
Creates a rotation matrix.
Name Type Description angleNumber The angle, in radians, of the rotation. Positive angles are counterclockwise. resultMatrix2 optional The object in which the result will be stored, if undefined a new instance will be created. Returns:
The modified result parameter, or a new Matrix2 instance if one was not provided.Example:
// Rotate a point 45 degrees counterclockwise. var p = new Cesium.Cartesian2(5, 6); var m = Cesium.Matrix2.fromRotation(Cesium.Math.toRadians(45.0)); var rotated = Cesium.Matrix2.multiplyByVector(m, p);Source: Core/Matrix2.js, line 225 -
staticMatrix2.fromRowMajorArray(values, result)
-
Creates a Matrix2 instance from a row-major order array. The resulting matrix will be in column-major order.
Name Type Description valuesArray.<Number> The row-major order array. resultMatrix2 optional The object in which the result will be stored, if undefined a new instance will be created. Returns:
The modified result parameter, or a new Matrix2 instance if one was not provided.Source: Core/Matrix2.js, line 128 -
staticMatrix2.fromScale(scale, result)
-
Computes a Matrix2 instance representing a non-uniform scale.
Name Type Description scaleCartesian2 The x and y scale factors. resultMatrix2 optional The object in which the result will be stored, if undefined a new instance will be created. Returns:
The modified result parameter, or a new Matrix2 instance if one was not provided.Example:
// Creates // [7.0, 0.0] // [0.0, 8.0] var m = Cesium.Matrix2.fromScale(new Cesium.Cartesian2(7.0, 8.0));Source: Core/Matrix2.js, line 159 -
staticMatrix2.fromUniformScale(scale, result)
-
Computes a Matrix2 instance representing a uniform scale.
Name Type Description scaleNumber The uniform scale factor. resultMatrix2 optional The object in which the result will be stored, if undefined a new instance will be created. Returns:
The modified result parameter, or a new Matrix2 instance if one was not provided.Example:
// Creates // [2.0, 0.0] // [0.0, 2.0] var m = Cesium.Matrix2.fromUniformScale(2.0);Source: Core/Matrix2.js, line 192 -
staticMatrix2.getColumn(matrix, index, result) → Cartesian2
-
Retrieves a copy of the matrix column at the provided index as a Cartesian2 instance.
Name Type Description matrixMatrix2 The matrix to use. indexNumber The zero-based index of the column to retrieve. resultCartesian2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian2 instance if one was not provided.Throws:
-
DeveloperError : index must be 0 or 1.
Source: Core/Matrix2.js, line 311 -
-
staticMatrix2.getElementIndex(row, column) → Number
-
Computes the array index of the element at the provided row and column.
Name Type Description rowNumber The zero-based index of the row. columnNumber The zero-based index of the column. Returns:
The index of the element at the provided row and column.Throws:
-
DeveloperError : row must be 0 or 1.
-
DeveloperError : column must be 0 or 1.
Example:
var myMatrix = new Cesium.Matrix2(); var column1Row0Index = Cesium.Matrix2.getElementIndex(1, 0); var column1Row0 = myMatrix[column1Row0Index] myMatrix[column1Row0Index] = 10.0;Source: Core/Matrix2.js, line 288 -
-
staticMatrix2.getMaximumScale(matrix) → Number
-
Computes the maximum scale assuming the matrix is an affine transformation. The maximum scale is the maximum length of the column vectors.
Name Type Description matrixMatrix2 The matrix. Returns:
The maximum scale.Source: Core/Matrix2.js, line 461 -
staticMatrix2.getRow(matrix, index, result) → Cartesian2
-
Retrieves a copy of the matrix row at the provided index as a Cartesian2 instance.
Name Type Description matrixMatrix2 The matrix to use. indexNumber The zero-based index of the row to retrieve. resultCartesian2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian2 instance if one was not provided.Throws:
-
DeveloperError : index must be 0 or 1.
Source: Core/Matrix2.js, line 375 -
-
staticMatrix2.getScale(matrix, result) → Cartesian2
-
Extracts the non-uniform scale assuming the matrix is an affine transformation.
Name Type Description matrixMatrix2 The matrix. resultCartesian2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian2 instance if one was not provided.Source: Core/Matrix2.js, line 436 -
staticMatrix2.multiply(left, right, result) → Matrix2
-
Computes the product of two matrices.
Name Type Description leftMatrix2 The first matrix. rightMatrix2 The second matrix. resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Source: Core/Matrix2.js, line 474 -
staticMatrix2.multiplyByScalar(matrix, scalar, result) → Matrix2
-
Computes the product of a matrix and a scalar.
Name Type Description matrixMatrix2 The matrix. scalarNumber The number to multiply by. resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian2 instance if one was not provided.Source: Core/Matrix2.js, line 537 -
staticMatrix2.multiplyByVector(matrix, cartesian, result) → Cartesian2
-
Computes the product of a matrix and a column vector.
Name Type Description matrixMatrix2 The matrix. cartesianCartesian2 The column. resultCartesian2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian2 instance if one was not provided.Source: Core/Matrix2.js, line 508 -
staticMatrix2.negate(matrix, result) → Matrix2
-
Creates a negated copy of the provided matrix.
Name Type Description matrixMatrix2 The matrix to negate. resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Source: Core/Matrix2.js, line 565 -
staticMatrix2.setColumn(matrix, index, cartesian, result) → Matrix2
-
Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian2 instance.
Name Type Description matrixMatrix2 The matrix to use. indexNumber The zero-based index of the column to set. cartesianCartesian2 The Cartesian whose values will be assigned to the specified column. resultCartesian2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Throws:
-
DeveloperError : index must be 0 or 1.
Source: Core/Matrix2.js, line 345 -
-
staticMatrix2.setRow(matrix, index, cartesian, result) → Matrix2
-
Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian2 instance.
Name Type Description matrixMatrix2 The matrix to use. indexNumber The zero-based index of the row to set. cartesianCartesian2 The Cartesian whose values will be assigned to the specified row. resultCartesian2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Throws:
-
DeveloperError : index must be 0 or 1.
Source: Core/Matrix2.js, line 408 -
-
staticMatrix2.toArray(matrix, result) → Array.<Number>
-
Creates an Array from the provided Matrix2 instance. The array will be in column-major order.
Name Type Description matrixMatrix2 The matrix to use.. resultArray.<Number> optional The Array onto which to store the result. Returns:
The modified Array parameter or a new Array instance if one was not provided.Source: Core/Matrix2.js, line 255 -
staticMatrix2.transpose(matrix, result) → Matrix2
-
Computes the transpose of the provided matrix.
Name Type Description matrixMatrix2 The matrix to transpose. resultMatrix2 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix2 instance if one was not provided.Source: Core/Matrix2.js, line 590
