new Matrix3
A 3x3 matrix, indexable as a column-major order array. Constructor parameters are in row-major order for code readability.
Parameters:
Name | Type | Argument | 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. |
- Matrix3.fromColumnMajor
- Matrix3.fromRowMajorArray
- Matrix3.fromQuaternion
- Matrix3.fromScale
- Matrix3.fromUniformScale
- Matrix2
- Matrix4
See:
Source:
Members
-
<static> COLUMN0ROW0
-
The index into Matrix3 for column 0, row 0.
-
<static> COLUMN0ROW1
-
The index into Matrix3 for column 0, row 1.
-
<static> COLUMN0ROW2
-
The index into Matrix3 for column 0, row 2.
-
<static> COLUMN1ROW0
-
The index into Matrix3 for column 1, row 0.
-
<static> COLUMN1ROW1
-
The index into Matrix3 for column 1, row 1.
-
<static> COLUMN1ROW2
-
The index into Matrix3 for column 1, row 2.
-
<static> COLUMN2ROW0
-
The index into Matrix3 for column 2, row 0.
-
<static> COLUMN2ROW1
-
The index into Matrix3 for column 2, row 1.
-
<static> COLUMN2ROW2
-
The index into Matrix3 for column 2, row 2.
-
<static> IDENTITY
-
An immutable Matrix3 instance initialized to the identity matrix.
Methods
-
clone
-
Duplicates the provided Matrix3 instance.
Parameters:
Name Type Argument Description result
Matrix3 <optional>
The object onto which to store the result. Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided. -
equals
-
Compares this matrix to the provided matrix componentwise and returns
true
if they are equal,false
otherwise.Parameters:
Name Type Argument Description right
Matrix3 <optional>
The right hand side matrix. Returns:
Booleantrue
if they are equal,false
otherwise. -
equalsEpsilon
-
Compares this matrix to the provided matrix componentwise and returns
true
if they are within the provided epsilon,false
otherwise.Parameters:
Name Type Argument Description right
Matrix3 <optional>
The right hand side matrix. epsilon
Number The epsilon to use for equality testing. Throws:
DeveloperError : epsilon is required and must be a number.Returns:
Booleantrue
if they are within the provided epsilon,false
otherwise. -
getColumn
-
Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.
Parameters:
Name Type Argument Description index
Number The zero-based index of the column to retrieve. result
Cartesian3 <optional>
The object onto which to store the result. Throws:
DeveloperError : index is required and must be 0, 1, or 2.Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided.See:
-
getRow
-
Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.
Parameters:
Name Type Argument Description index
Number The zero-based index of the row to retrieve. result
Cartesian3 <optional>
The object onto which to store the result. Throws:
DeveloperError : index is required and must be 0, 1, or 2.Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided.See:
-
multiply
-
Computes the product of this matrix and the provided matrix.
Parameters:
Name Type Argument Description right
Matrix3 The right hand side matrix. result
Matrix3 <optional>
The object onto which to store the result. Throws:
DeveloperError : right is required.Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided. -
multiplyByScalar
-
Computes the product of this matrix and a scalar.
Parameters:
Name Type Argument Description scalar
Number The number to multiply by. result
Matrix3 <optional>
The object onto which to store the result. Throws:
DeveloperError : scalar is required and must be a number.Returns:
Matrix3 The modified result parameter or a new Cartesian3 instance if one was not provided. -
multiplyByVector
-
Computes the product of this matrix and a column vector.
Parameters:
Name Type Argument Description cartesian
Cartesian3 The column. result
Cartesian3 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided. -
negate
-
Creates a negated copy of this matrix.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix to negate. result
Matrix3 <optional>
The object onto which to store the result. Throws:
DeveloperError : matrix is required.Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided. -
setColumn
-
Computes a new matrix that replaces the specified column in this matrix with the provided Cartesian3 instance.
Parameters:
Name Type Description index
Number The zero-based index of the column to set. cartesian
Cartesian3 The Cartesian whose values will be assigned to the specified column. Throws:
-
DeveloperError : cartesian is required.
-
DeveloperError : index is required and must be 0, 1, or 2.
See:
-
-
setRow
-
Computes a new matrix that replaces the specified row in this matrix with the provided Cartesian3 instance.
Parameters:
Name Type Description index
Number The zero-based index of the row to set. cartesian
Cartesian3 The Cartesian whose values will be assigned to the specified row. Throws:
-
DeveloperError : cartesian is required.
-
DeveloperError : index is required and must be 0, 1, or 2.
See:
-
-
toArray
-
Creates an Array from this Matrix3 instance.
Parameters:
Name Type Argument Description result
Array <optional>
The Array onto which to store the result. Returns:
Array The modified Array parameter or a new Array instance if one was not provided. -
toString
-
Creates a string representing this Matrix with each row being on a separate line and in the format '(column0, column1, column2)'.
Returns:
String A string representing the provided Matrix with each row being on a separate line and in the format '(column0, column1, column2)'. -
transpose
-
Computes the transpose of this matrix.
Parameters:
Name Type Argument Description result
Matrix3 <optional>
The object onto which to store the result. Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided. -
<static> clone
-
Duplicates a Matrix3 instance.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix to duplicate. result
Matrix3 <optional>
The object onto which to store the result. Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided. (Returns undefined if matrix is undefined) -
<static> equals
-
Compares the provided matrices componentwise and returns
true
if they are equal,false
otherwise.Parameters:
Name Type Argument Description left
Matrix3 <optional>
The first matrix. right
Matrix3 <optional>
The second matrix. Returns:
Booleantrue
if left and right are equal,false
otherwise. -
<static> equalsEpsilon
-
Compares the provided matrices componentwise and returns
true
if they are within the provided epsilon,false
otherwise.Parameters:
Name Type Argument Description left
Matrix3 <optional>
The first matrix. right
Matrix3 <optional>
The second matrix. epsilon
Number The epsilon to use for equality testing. Throws:
DeveloperError : epsilon is required and must be a number.Returns:
Booleantrue
if left and right are within the provided epsilon,false
otherwise. -
<static> fromColumnMajorArray
-
Creates a Matrix3 instance from a column-major order array.
Parameters:
Name Type Argument Description values
Array 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. Throws:
DeveloperError : values is required.Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided. -
<static> fromQuaternion
-
Computes a 3x3 rotation matrix from the provided quaternion.
Parameters:
Name Type Description quaternion
Quaternion the quaternion to use. Returns:
Matrix3 The 3x3 rotation matrix from this quaternion. -
<static> fromRotationX
-
Creates a rotation matrix around the x-axis.
Parameters:
Name Type Argument 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. Throws:
DeveloperError : angle is required.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. var p = new Cartesian3(5, 6, 7); var m = Matrix3.fromRotationX(CesiumMath.toRadians(45.0)); var rotated = m.multiplyByVector(p);
-
<static> fromRotationY
-
Creates a rotation matrix around the y-axis.
Parameters:
Name Type Argument 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. Throws:
DeveloperError : angle is required.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. var p = new Cartesian3(5, 6, 7); var m = Matrix3.fromRotationY(CesiumMath.toRadians(45.0)); var rotated = m.multiplyByVector(p);
-
<static> fromRotationZ
-
Creates a rotation matrix around the z-axis.
Parameters:
Name Type Argument 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. Throws:
DeveloperError : angle is required.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. var p = new Cartesian3(5, 6, 7); var m = Matrix3.fromRotationZ(CesiumMath.toRadians(45.0)); var rotated = m.multiplyByVector(p);
-
<static> fromRowMajorArray
-
Creates a Matrix3 instance from a row-major order array. The resulting matrix will be in column-major order.
Parameters:
Name Type Argument Description values
Array 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. Throws:
DeveloperError : values is required.Returns:
The modified result parameter, or a new Matrix3 instance if one was not provided. -
<static> fromScale
-
Computes a Matrix3 instance representing a non-uniform scale.
Parameters:
Name Type Argument 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. Throws:
DeveloperError : scale is required.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] var m = Matrix3.fromScale(new Cartesian3(7.0, 8.0, 9.0));
-
<static> fromUniformScale
-
Computes a Matrix3 instance representing a uniform scale.
Parameters:
Name Type Argument 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. Throws:
DeveloperError : scale is required.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] var m = Matrix3.fromUniformScale(2.0);
-
<static> getColumn
-
Retrieves a copy of the matrix column at the provided index as a Cartesian3 instance.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix to use. index
Number The zero-based index of the column to retrieve. result
Cartesian3 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : matrix is required.
-
DeveloperError : index is required and must be 0, 1, or 2.
Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided.See:
-
-
<static> getElementIndex
-
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. Throws:
-
DeveloperError : row is required and must be 0, 1, or 2.
-
DeveloperError : column is required and must be 0, 1, or 2.
Returns:
Number The index of the element at the provided row and column.Example
var myMatrix = new Matrix3(); var column1Row0Index = Matrix3.getElementIndex(1, 0); var column1Row0 = myMatrix[column1Row0Index] myMatrix[column1Row0Index] = 10.0;
-
-
<static> getRow
-
Retrieves a copy of the matrix row at the provided index as a Cartesian3 instance.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix to use. index
Number The zero-based index of the row to retrieve. result
Cartesian3 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : matrix is required.
-
DeveloperError : index is required and must be 0, 1, or 2.
Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided.See:
-
-
<static> multiply
-
Computes the product of two matrices.
Parameters:
Name Type Argument Description left
Matrix3 The first matrix. right
Matrix3 The second matrix. result
Matrix3 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided. -
-
<static> multiplyByScalar
-
Computes the product of a matrix and a scalar.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix. scalar
Number The number to multiply by. result
Matrix3 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : matrix is required.
-
DeveloperError : scalar is required and must be a number.
Returns:
Matrix3 The modified result parameter or a new Cartesian3 instance if one was not provided. -
-
<static> multiplyByVector
-
Computes the product of a matrix and a column vector.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix. cartesian
Cartesian3 The column. result
Cartesian3 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : matrix is required.
-
DeveloperError : cartesian is required.
Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided. -
-
<static> negate
-
Creates a negated copy of the provided matrix.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix to negate. result
Matrix3 <optional>
The object onto which to store the result. Throws:
DeveloperError : matrix is required.Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided. -
<static> setColumn
-
Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian3 instance.
Parameters:
Name Type Argument 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
Cartesian3 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : matrix is required.
-
DeveloperError : cartesian is required.
-
DeveloperError : index is required and must be 0, 1, or 2.
Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided.See:
-
-
<static> setRow
-
Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian3 instance.
Parameters:
Name Type Argument 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
Cartesian3 <optional>
The object onto which to store the result. Throws:
-
DeveloperError : matrix is required.
-
DeveloperError : cartesian is required.
-
DeveloperError : index is required and must be 0, 1, or 2.
Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided.See:
-
-
<static> toArray
-
Creates an Array from the provided Matrix3 instance. The array will be in column-major order.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix to use.. result
Array <optional>
The Array onto which to store the result. Throws:
DeveloperError : matrix is required.Returns:
Array The modified Array parameter or a new Array instance if one was not provided. -
<static> transpose
-
Computes the transpose of the provided matrix.
Parameters:
Name Type Argument Description matrix
Matrix3 The matrix to transpose. result
Matrix3 <optional>
The object onto which to store the result. Throws:
DeveloperError : matrix is required.Returns:
Matrix3 The modified result parameter or a new Matrix3 instance if one was not provided.