new Matrix3(column0Row0opt, column1Row0opt, column2Row0opt, column0Row1opt, column1Row1opt, column2Row1opt, column0Row2opt, column1Row2opt, column2Row2opt)
A 3x3 matrix, indexable as a column-major order array.
Constructor parameters are in row-major order for code readability.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
column0Row0 |
Number |
<optional> |
0.0 | The value for column 0, row 0. |
column1Row0 |
Number |
<optional> |
0.0 | The value for column 1, row 0. |
column2Row0 |
Number |
<optional> |
0.0 | The value for column 2, row 0. |
column0Row1 |
Number |
<optional> |
0.0 | The value for column 0, row 1. |
column1Row1 |
Number |
<optional> |
0.0 | The value for column 1, row 1. |
column2Row1 |
Number |
<optional> |
0.0 | The value for column 2, row 1. |
column0Row2 |
Number |
<optional> |
0.0 | The value for column 0, row 2. |
column1Row2 |
Number |
<optional> |
0.0 | The value for column 1, row 2. |
column2Row2 |
Number |
<optional> |
0.0 | The value for column 2, row 2. |
Members
length :Number
Gets the number of items in the collection.
Type:
- Number
- Source:
(static, constant) COLUMN0ROW0 :Number
The index into Matrix3 for column 0, row 0.
Type:
- Number
- Source:
(static, constant) COLUMN0ROW1 :Number
The index into Matrix3 for column 0, row 1.
Type:
- Number
- Source:
(static, constant) COLUMN0ROW2 :Number
The index into Matrix3 for column 0, row 2.
Type:
- Number
- Source:
(static, constant) COLUMN1ROW0 :Number
The index into Matrix3 for column 1, row 0.
Type:
- Number
- Source:
(static, constant) COLUMN1ROW1 :Number
The index into Matrix3 for column 1, row 1.
Type:
- Number
- Source:
(static, constant) COLUMN1ROW2 :Number
The index into Matrix3 for column 1, row 2.
Type:
- Number
- Source:
(static, constant) COLUMN2ROW0 :Number
The index into Matrix3 for column 2, row 0.
Type:
- Number
- Source:
(static, constant) COLUMN2ROW1 :Number
The index into Matrix3 for column 2, row 1.
Type:
- Number
- Source:
(static, constant) COLUMN2ROW2 :Number
The index into Matrix3 for column 2, row 2.
Type:
- Number
- Source:
(static, constant) IDENTITY :Matrix3
An immutable Matrix3 instance initialized to the identity matrix.
Type:
- Source:
(static) packedLength :Number
The number of elements used to pack the object into an array.
Type:
- Number
- Source:
(static, constant) ZERO :Matrix3
An immutable Matrix3 instance initialized to the zero matrix.
Type:
- Source:
Methods
clone(resultopt) → {Matrix3}
Duplicates the provided Matrix3 instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
result |
Matrix3 |
<optional> |
The object onto which to store the result. |
- Source:
Returns:
The modified result parameter or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
equals(rightopt) → {Boolean}
Compares this matrix to the provided matrix componentwise and returns
true
if they are equal, false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
right |
Matrix3 |
<optional> |
The right hand side matrix. |
- Source:
Returns:
true
if they are equal, false
otherwise.
- Type
- Boolean
equalsEpsilon(rightopt, epsilon) → {Boolean}
Compares this matrix to the provided matrix componentwise and returns
true
if they are within the provided epsilon,
false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
right |
Matrix3 |
<optional> |
The right hand side matrix. |
epsilon |
Number | The epsilon to use for equality testing. |
- Source:
Returns:
true
if they are within the provided epsilon, false
otherwise.
- Type
- Boolean
toString() → {String}
Creates a string representing this Matrix with each row being
on a separate line and in the format '(column0, column1, column2)'.
- Source:
Returns:
A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2)'.
- Type
- String
(static) abs(matrix, result) → {Matrix3}
Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix with signed elements. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Matrix3
(static) add(left, right, result) → {Matrix3}
Computes the sum of two matrices.
Parameters:
Name | Type | Description |
---|---|---|
left |
Matrix3 | The first matrix. |
right |
Matrix3 | The second matrix. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Matrix3
(static) clone(matrix, resultopt) → {Matrix3}
Duplicates a Matrix3 instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
matrix |
Matrix3 | The matrix to duplicate. | |
result |
Matrix3 |
<optional> |
The object onto which to store the result. |
- Source:
Returns:
The modified result parameter or a new Matrix3 instance if one was not provided. (Returns undefined if matrix is undefined)
- Type
- Matrix3
(static) computeEigenDecomposition(matrix, resultopt) → {Object}
Computes the eigenvectors and eigenvalues of a symmetric matrix.
Returns a diagonal matrix and unitary matrix such that:
matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)
The values along the diagonal of the diagonal matrix are the eigenvalues. The columns of the unitary matrix are the corresponding eigenvectors.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
matrix |
Matrix3 | The matrix to decompose into diagonal and unitary matrix. Expected to be symmetric. | |
result |
Object |
<optional> |
An object with unitary and diagonal properties which are matrices onto which to store the result. |
- Source:
Returns:
An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.
- Type
- Object
Example
var a = //... symetric matrix
var result = {
unitary : new Cesium.Matrix3(),
diagonal : new Cesium.Matrix3()
};
Cesium.Matrix3.computeEigenDecomposition(a, result);
var unitaryTranspose = Cesium.Matrix3.transpose(result.unitary, new Cesium.Matrix3());
var b = Cesium.Matrix3.multiply(result.unitary, result.diagonal, new Cesium.Matrix3());
Cesium.Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a
var lambda = Cesium.Matrix3.getColumn(result.diagonal, 0, new Cesium.Cartesian3()).x; // first eigenvalue
var v = Cesium.Matrix3.getColumn(result.unitary, 0, new Cesium.Cartesian3()); // first eigenvector
var c = Cesium.Cartesian3.multiplyByScalar(v, lambda, new Cesium.Cartesian3()); // equal to Cesium.Matrix3.multiplyByVector(a, v)
(static) determinant(matrix) → {Number}
Computes the determinant of the provided matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to use. |
- Source:
Returns:
The value of the determinant of the matrix.
- Type
- Number
(static) equals(leftopt, rightopt) → {Boolean}
Compares the provided matrices componentwise and returns
true
if they are equal, false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
left |
Matrix3 |
<optional> |
The first matrix. |
right |
Matrix3 |
<optional> |
The second matrix. |
- Source:
Returns:
true
if left and right are equal, false
otherwise.
- Type
- Boolean
(static) equalsEpsilon(leftopt, rightopt, epsilon) → {Boolean}
Compares the provided matrices componentwise and returns
true
if they are within the provided epsilon,
false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
left |
Matrix3 |
<optional> |
The first matrix. |
right |
Matrix3 |
<optional> |
The second matrix. |
epsilon |
Number | The epsilon to use for equality testing. |
- Source:
Returns:
true
if left and right are within the provided epsilon, false
otherwise.
- Type
- Boolean
(static) fromArray(array, startingIndexopt, resultopt) → {Matrix3}
Creates a Matrix3 from 9 consecutive elements in an array.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array |
Array.<Number> | The array whose 9 consecutive elements correspond to the positions of the matrix. Assumes column-major order. | ||
startingIndex |
Number |
<optional> |
0 | The offset into the array of the first element, which corresponds to first column first row position in the matrix. |
result |
Matrix3 |
<optional> |
The object onto which to store the result. |
- Source:
Returns:
The modified result parameter or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
Example
// Create the Matrix3:
// [1.0, 2.0, 3.0]
// [1.0, 2.0, 3.0]
// [1.0, 2.0, 3.0]
var v = [1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];
var m = Cesium.Matrix3.fromArray(v);
// Create same Matrix3 with using an offset into an array
var v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0];
var m2 = Cesium.Matrix3.fromArray(v2, 2);
(static) fromColumnMajorArray(values, resultopt) → {Matrix3}
Creates a Matrix3 instance from a column-major order array.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
values |
Array.<Number> | The column-major order array. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
(static) fromCrossProduct(the, resultopt) → {Matrix3}
Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
the |
Cartesian3 | vector on the left hand side of the cross product operation. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
Example
// Creates
// [0.0, -9.0, 8.0]
// [9.0, 0.0, -7.0]
// [-8.0, 7.0, 0.0]
var m = Cesium.Matrix3.fromCrossProduct(new Cesium.Cartesian3(7.0, 8.0, 9.0));
(static) fromHeadingPitchRoll(headingPitchRoll, resultopt) → {Matrix3}
Computes a 3x3 rotation matrix from the provided headingPitchRoll. (see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles )
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
headingPitchRoll |
HeadingPitchRoll | the headingPitchRoll to use. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The 3x3 rotation matrix from this headingPitchRoll.
- Type
- Matrix3
(static) fromQuaternion(quaternion, resultopt) → {Matrix3}
Computes a 3x3 rotation matrix from the provided quaternion.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
quaternion |
Quaternion | the quaternion to use. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The 3x3 rotation matrix from this quaternion.
- Type
- Matrix3
(static) fromRotationX(angle, resultopt) → {Matrix3}
Creates a rotation matrix around the x-axis.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
angle |
Number | The angle, in radians, of the rotation. Positive angles are counterclockwise. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
Example
// Rotate a point 45 degrees counterclockwise around the x-axis.
var p = new Cesium.Cartesian3(5, 6, 7);
var m = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(45.0));
var rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
(static) fromRotationY(angle, resultopt) → {Matrix3}
Creates a rotation matrix around the y-axis.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
angle |
Number | The angle, in radians, of the rotation. Positive angles are counterclockwise. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
Example
// Rotate a point 45 degrees counterclockwise around the y-axis.
var p = new Cesium.Cartesian3(5, 6, 7);
var m = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(45.0));
var rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
(static) fromRotationZ(angle, resultopt) → {Matrix3}
Creates a rotation matrix around the z-axis.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
angle |
Number | The angle, in radians, of the rotation. Positive angles are counterclockwise. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
Example
// Rotate a point 45 degrees counterclockwise around the z-axis.
var p = new Cesium.Cartesian3(5, 6, 7);
var m = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(45.0));
var rotated = Cesium.Matrix3.multiplyByVector(m, p, new Cesium.Cartesian3());
(static) fromRowMajorArray(values, resultopt) → {Matrix3}
Creates a Matrix3 instance from a row-major order array.
The resulting matrix will be in column-major order.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
values |
Array.<Number> | The row-major order array. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
(static) fromScale(scale, resultopt) → {Matrix3}
Computes a Matrix3 instance representing a non-uniform scale.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scale |
Cartesian3 | The x, y, and z scale factors. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
Example
// Creates
// [7.0, 0.0, 0.0]
// [0.0, 8.0, 0.0]
// [0.0, 0.0, 9.0]
var m = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(7.0, 8.0, 9.0));
(static) fromUniformScale(scale, resultopt) → {Matrix3}
Computes a Matrix3 instance representing a uniform scale.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scale |
Number | The uniform scale factor. | |
result |
Matrix3 |
<optional> |
The object in which the result will be stored, if undefined a new instance will be created. |
- Source:
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
- Type
- Matrix3
Example
// Creates
// [2.0, 0.0, 0.0]
// [0.0, 2.0, 0.0]
// [0.0, 0.0, 2.0]
var m = Cesium.Matrix3.fromUniformScale(2.0);
(static) getColumn(matrix, index, result) → {Cartesian3}
Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to use. |
index |
Number | The zero-based index of the column to retrieve. |
result |
Cartesian3 | The object onto which to store the result. |
- Source:
Throws:
-
index must be 0, 1, or 2.
- Type
- DeveloperError
Returns:
The modified result parameter.
- Type
- Cartesian3
(static) getElementIndex(row, column) → {Number}
Computes the array index of the element at the provided row and column.
Parameters:
Name | Type | Description |
---|---|---|
row |
Number | The zero-based index of the row. |
column |
Number | The zero-based index of the column. |
- Source:
Throws:
-
-
row must be 0, 1, or 2.
- Type
- DeveloperError
-
-
-
column must be 0, 1, or 2.
- Type
- DeveloperError
-
Returns:
The index of the element at the provided row and column.
- Type
- Number
Example
var myMatrix = new Cesium.Matrix3();
var column1Row0Index = Cesium.Matrix3.getElementIndex(1, 0);
var column1Row0 = myMatrix[column1Row0Index]
myMatrix[column1Row0Index] = 10.0;
(static) 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.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix. |
- Source:
Returns:
The maximum scale.
- Type
- Number
(static) getRow(matrix, index, result) → {Cartesian3}
Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to use. |
index |
Number | The zero-based index of the row to retrieve. |
result |
Cartesian3 | The object onto which to store the result. |
- Source:
Throws:
-
index must be 0, 1, or 2.
- Type
- DeveloperError
Returns:
The modified result parameter.
- Type
- Cartesian3
(static) getScale(matrix, result) → {Cartesian3}
Extracts the non-uniform scale assuming the matrix is an affine transformation.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix. |
result |
Cartesian3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Cartesian3
(static) inverse(matrix, result) → {Matrix3}
Computes the inverse of the provided matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to invert. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Throws:
-
matrix is not invertible.
- Type
- DeveloperError
Returns:
The modified result parameter.
- Type
- Matrix3
(static) multiply(left, right, result) → {Matrix3}
Computes the product of two matrices.
Parameters:
Name | Type | Description |
---|---|---|
left |
Matrix3 | The first matrix. |
right |
Matrix3 | The second matrix. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Matrix3
(static) multiplyByScalar(matrix, scalar, result) → {Matrix3}
Computes the product of a matrix and a scalar.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix. |
scalar |
Number | The number to multiply by. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Matrix3
(static) multiplyByScale(matrix, scale, result) → {Matrix3}
Computes the product of a matrix times a (non-uniform) scale, as if the scale were a scale matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix on the left-hand side. |
scale |
Cartesian3 | The non-uniform scale on the right-hand side. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
- See:
-
- Matrix3.fromScale
- Matrix3.multiplyByUniformScale
Returns:
The modified result parameter.
- Type
- Matrix3
Example
// Instead of Cesium.Matrix3.multiply(m, Cesium.Matrix3.fromScale(scale), m);
Cesium.Matrix3.multiplyByScale(m, scale, m);
(static) multiplyByVector(matrix, cartesian, result) → {Cartesian3}
Computes the product of a matrix and a column vector.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix. |
cartesian |
Cartesian3 | The column. |
result |
Cartesian3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Cartesian3
(static) negate(matrix, result) → {Matrix3}
Creates a negated copy of the provided matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to negate. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Matrix3
(static) pack(value, array, startingIndexopt) → {Array.<Number>}
Stores the provided instance into the provided array.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
Matrix3 | The value to pack. | ||
array |
Array.<Number> | The array to pack into. | ||
startingIndex |
Number |
<optional> |
0 | The index into the array at which to start packing the elements. |
- Source:
Returns:
The array that was packed into
- Type
- Array.<Number>
(static) setColumn(matrix, index, cartesian, result) → {Matrix3}
Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to use. |
index |
Number | The zero-based index of the column to set. |
cartesian |
Cartesian3 | The Cartesian whose values will be assigned to the specified column. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Throws:
-
index must be 0, 1, or 2.
- Type
- DeveloperError
Returns:
The modified result parameter.
- Type
- Matrix3
(static) setRow(matrix, index, cartesian, result) → {Matrix3}
Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to use. |
index |
Number | The zero-based index of the row to set. |
cartesian |
Cartesian3 | The Cartesian whose values will be assigned to the specified row. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Throws:
-
index must be 0, 1, or 2.
- Type
- DeveloperError
Returns:
The modified result parameter.
- Type
- Matrix3
(static) subtract(left, right, result) → {Matrix3}
Computes the difference of two matrices.
Parameters:
Name | Type | Description |
---|---|---|
left |
Matrix3 | The first matrix. |
right |
Matrix3 | The second matrix. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Matrix3
(static) toArray(matrix, resultopt) → {Array.<Number>}
Creates an Array from the provided Matrix3 instance.
The array will be in column-major order.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
matrix |
Matrix3 | The matrix to use.. | |
result |
Array.<Number> |
<optional> |
The Array onto which to store the result. |
- Source:
Returns:
The modified Array parameter or a new Array instance if one was not provided.
- Type
- Array.<Number>
(static) transpose(matrix, result) → {Matrix3}
Computes the transpose of the provided matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Matrix3 | The matrix to transpose. |
result |
Matrix3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Matrix3
(static) unpack(array, startingIndexopt, resultopt) → {Matrix3}
Retrieves an instance from a packed array.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array |
Array.<Number> | The packed array. | ||
startingIndex |
Number |
<optional> |
0 | The starting index of the element to be unpacked. |
result |
Matrix3 |
<optional> |
The object into which to store the result. |
- Source:
Returns:
The modified result parameter or a new Matrix3 instance if one was not provided.
- Type
- Matrix3