new Matrix3(column0Row0, column1Row0, column2Row0, column0Row1, column1Row1, column2Row1, column0Row2, column1Row2, column2Row2)
A 3x3 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. |
column2Row0 |
Number |
0.0
|
optional
The value for column 2, 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. |
column2Row1 |
Number |
0.0
|
optional
The value for column 2, row 1. |
column0Row2 |
Number |
0.0
|
optional
The value for column 0, row 2. |
column1Row2 |
Number |
0.0
|
optional
The value for column 1, row 2. |
column2Row2 |
Number |
0.0
|
optional
The value for column 2, row 2. |
Members
static constant Matrix3.IDENTITY : Matrix3
An immutable Matrix3 instance initialized to the identity matrix.
Methods
Computes a string representing this Matrix with each row being on a separate line and in the format '(column0, column1, column2, column3)'.
Returns:
A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2, column3)'.
static Matrix3.clone(matrix, result) → Matrix3
Duplicates a Matrix3 instance.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix to duplicate. |
result |
Matrix3 |
optional
The object onto which to store the result. |
Returns:
The modified result parameter or a new Matrix3 instance if one was not provided. (Returns undefined if matrix is undefined)
Computes the determinant of the provided matrix.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix to use. |
Returns:
The value of the determinant of the matrix.
static Matrix3.fromColumnMajorArray(values, result) → Matrix3
Creates a Matrix3 instance from a column-major order array.
Name | Type | 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
static Matrix3.fromCrossProduct(vector, result) → Matrix3
Computes a Matrix3 instance representing the cross product equivalent matrix of a Cartesian3 vector.
Name | Type | Description |
---|---|---|
vector |
Cartesian3 |
the 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
Example:
// Creates
// [0.0, -9.0, 8.0]
// [9.0, 0.0, -7.0]
// [-8.0, 7.0, 0.0]
const m = Matrix3.fromCrossProduct(new Cartesian3(7.0, 8.0, 9.0));
static Matrix3.fromHeadingPitchRoll(headingPitchRoll, result) → Matrix3
Computes a 3x3 rotation matrix from the provided headingPitchRoll. (see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles )
Name | Type | 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. |
Returns:
The 3x3 rotation matrix from this headingPitchRoll.
static Matrix3.fromQuaternion(quaternion, result) → Matrix3
Computes a 3x3 rotation matrix from the provided quaternion.
Name | Type | 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. |
Returns:
The 3x3 rotation matrix from this quaternion.
static Matrix3.fromRotationX(angle, result) → Matrix3
Creates a rotation matrix around the x-axis.
Name | Type | 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
Example:
// Rotate a point 45 degrees counterclockwise around the x-axis.
const p = new Cartesian3(5, 6, 7);
const m = Matrix3.fromRotationX(Math.toRadians(45.0));
const rotated = Matrix3.multiplyByVector(m, p, new Cartesian3());
static Matrix3.fromRotationY(angle, result) → Matrix3
Creates a rotation matrix around the y-axis.
Name | Type | 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
Example:
// Rotate a point 45 degrees counterclockwise around the y-axis.
const p = new Cartesian3(5, 6, 7);
const m = Matrix3.fromRotationY(toRadians(45.0));
const rotated = Matrix3.multiplyByVector(m, p, new Cartesian3());
static Matrix3.fromRotationZ(angle, result) → Matrix3
Creates a rotation matrix around the z-axis.
Name | Type | 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
Example:
// Rotate a point 45 degrees counterclockwise around the z-axis.
const p = new Cartesian3(5, 6, 7);
const m = Matrix3.fromRotationZ(Math.toRadians(45.0));
const rotated = Matrix3.multiplyByVector(m, p, new Cartesian3());
static Matrix3.fromRowMajorArray(values, result) → Matrix3
Creates a Matrix3 instance from a row-major order array. The resulting matrix will be in column-major order.
Name | Type | 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
static Matrix3.fromScale(scale, result) → Matrix3
Computes a Matrix3 instance representing a non-uniform scale.
Name | Type | 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
Example:
// Creates
// [7.0, 0.0, 0.0]
// [0.0, 8.0, 0.0]
// [0.0, 0.0, 9.0]
const m = Matrix3.fromScale(new Cartesian3(7.0, 8.0, 9.0));
static Matrix3.fromUniformScale(scale, result) → Matrix3
Computes a Matrix3 instance representing a uniform scale.
Name | Type | 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. |
Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided.
Example:
// Creates
// [2.0, 0.0, 0.0]
// [0.0, 2.0, 0.0]
// [0.0, 0.0, 2.0]
const m = Matrix3.fromUniformScale(2.0);
static Matrix3.getColumn(matrix, index, result) → Cartesian3
Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.
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. |
Returns:
The modified result parameter.
static Matrix3.getRow(matrix, index, result) → Cartesian3
Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.
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. |
Returns:
The modified result parameter.
static Matrix3.getScale(matrix, result) → Cartesian3
Extracts the non-uniform scale assuming the matrix is an affine transformation.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix. |
result |
Cartesian3 |
The object onto which to store the result. |
Returns:
The modified result parameter.
static Matrix3.inverse(matrix, result) → Matrix3
Computes the inverse of the provided matrix.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix to invert. |
result |
Matrix3 |
The object onto which to store the result. |
Returns:
The modified result parameter.
Throws:
-
Error :
matrix is not invertible.
static Matrix3.multiplyByScalar(matrix, scalar, result) → Matrix3
Computes the product of a matrix and a scalar.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix. |
scalar |
Number |
The number to multiply by. |
result |
Matrix3 |
The object onto which to store the result. |
Returns:
The modified result parameter.
static Matrix3.multiplyByVector(matrix, cartesian, result) → Cartesian3
Computes the product of a matrix and a column vector.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix. |
cartesian |
Cartesian3 |
The column. |
result |
Cartesian3 |
The object onto which to store the result. |
Returns:
The modified result parameter.
static Matrix3.setColumn(matrix, index, cartesian, result) → Matrix3
Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.
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. |
Returns:
The modified result parameter.
static Matrix3.setRow(matrix, index, cartesian, result) → Matrix3
Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.
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. |
Returns:
The modified result parameter.
static Matrix3.setScale(matrix, scale, result) → Matrix3
Computes a new matrix that replaces the scale with the provided scale. This assumes the matrix is an affine transformation.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix to use. |
scale |
Cartesian3 |
The scale that replaces the scale of the provided matrix. |
result |
Matrix3 |
The object onto which to store the result. |
Returns:
The modified result parameter.
static Matrix3.setUniformScale(matrix, scale, result) → Matrix3
Computes a new matrix that replaces the scale with the provided uniform scale. This assumes the matrix is an affine transformation.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix to use. |
scale |
Number |
The uniform scale that replaces the scale of the provided matrix. |
result |
Matrix3 |
The object onto which to store the result. |
Returns:
The modified result parameter.
static Matrix3.transpose(matrix, result) → Matrix3
Computes the transpose of the provided matrix.
Name | Type | Description |
---|---|---|
matrix |
Matrix3 |
The matrix to transpose. |
result |
Matrix3 |
The object onto which to store the result. |
Returns:
The modified result parameter.