new Matrix4(column0Row0, column1Row0, column2Row0, column3Row0, column0Row1, column1Row1, column2Row1, column3Row1, column0Row2, column1Row2, column2Row2, column3Row2, column0Row3, column1Row3, column2Row3, column3Row3)
A 4x4 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. |
column3Row0 |
Number |
0.0
|
optional The value for column 3, 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. |
column3Row1 |
Number |
0.0
|
optional The value for column 3, 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. |
column3Row2 |
Number |
0.0
|
optional The value for column 3, row 2. |
column0Row3 |
Number |
0.0
|
optional The value for column 0, row 3. |
column1Row3 |
Number |
0.0
|
optional The value for column 1, row 3. |
column2Row3 |
Number |
0.0
|
optional The value for column 2, row 3. |
column3Row3 |
Number |
0.0
|
optional The value for column 3, row 3. |
- Matrix4.fromColumnMajorArray
- Matrix4.fromRowMajorArray
- Matrix4.fromRotationTranslation
- Matrix4.fromTranslationQuaternionRotationScale
- Matrix4.fromTranslation
- Matrix4.fromScale
- Matrix4.fromUniformScale
- Matrix4.fromCamera
- Matrix4.computePerspectiveFieldOfView
- Matrix4.computeOrthographicOffCenter
- Matrix4.computePerspectiveOffCenter
- Matrix4.computeInfinitePerspectiveOffCenter
- Matrix4.computeViewportTransformation
- Matrix2
- Matrix3
- Packable
See:
Source:
Core/Matrix4.js, line 64
Members
-
staticMatrix4.COLUMN0ROW0
-
The index into Matrix4 for column 0, row 0.Source: Core/Matrix4.js, line 2415
-
staticMatrix4.COLUMN0ROW1
-
The index into Matrix4 for column 0, row 1.Source: Core/Matrix4.js, line 2421
-
staticMatrix4.COLUMN0ROW2
-
The index into Matrix4 for column 0, row 2.Source: Core/Matrix4.js, line 2427
-
staticMatrix4.COLUMN0ROW3
-
The index into Matrix4 for column 0, row 3.Source: Core/Matrix4.js, line 2433
-
staticMatrix4.COLUMN1ROW0
-
The index into Matrix4 for column 1, row 0.Source: Core/Matrix4.js, line 2439
-
staticMatrix4.COLUMN1ROW1
-
The index into Matrix4 for column 1, row 1.Source: Core/Matrix4.js, line 2445
-
staticMatrix4.COLUMN1ROW2
-
The index into Matrix4 for column 1, row 2.Source: Core/Matrix4.js, line 2451
-
staticMatrix4.COLUMN1ROW3
-
The index into Matrix4 for column 1, row 3.Source: Core/Matrix4.js, line 2457
-
staticMatrix4.COLUMN2ROW0
-
The index into Matrix4 for column 2, row 0.Source: Core/Matrix4.js, line 2463
-
staticMatrix4.COLUMN2ROW1
-
The index into Matrix4 for column 2, row 1.Source: Core/Matrix4.js, line 2469
-
staticMatrix4.COLUMN2ROW2
-
The index into Matrix4 for column 2, row 2.Source: Core/Matrix4.js, line 2475
-
staticMatrix4.COLUMN2ROW3
-
The index into Matrix4 for column 2, row 3.Source: Core/Matrix4.js, line 2481
-
staticMatrix4.COLUMN3ROW0
-
The index into Matrix4 for column 3, row 0.Source: Core/Matrix4.js, line 2487
-
staticMatrix4.COLUMN3ROW1
-
The index into Matrix4 for column 3, row 1.Source: Core/Matrix4.js, line 2493
-
staticMatrix4.COLUMN3ROW2
-
The index into Matrix4 for column 3, row 2.Source: Core/Matrix4.js, line 2499
-
staticMatrix4.COLUMN3ROW3
-
The index into Matrix4 for column 3, row 3.Source: Core/Matrix4.js, line 2505
-
staticMatrix4.fromArray
-
Creates a Matrix4 from 16 consecutive elements in an array.
Example:
// Create the Matrix4: // [1.0, 2.0, 3.0, 4.0] // [1.0, 2.0, 3.0, 4.0] // [1.0, 2.0, 3.0, 4.0] // [1.0, 2.0, 3.0, 4.0] var v = [1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0]; var m = Cesium.Matrix4.fromArray(v); // Create same Matrix4 with using an offset into an array var v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0]; var m2 = Cesium.Matrix4.fromArray(v2, 2);
Source: Core/Matrix4.js, line 232 -
staticMatrix4.IDENTITY
-
An immutable Matrix4 instance initialized to the identity matrix.Source: Core/Matrix4.js, line 2406
-
staticMatrix4.packedLength :Number
-
The number of elements used to pack the object into an array.Source: Core/Matrix4.js, line 90
Methods
-
clone(result) → Matrix4
-
Duplicates the provided Matrix4 instance.
Name Type Description result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 2514 -
equals(right) → Boolean
-
Compares this matrix to the provided matrix componentwise and returns
true
if they are equal,false
otherwise.Name Type Description right
Matrix4 optional The right hand side matrix. Returns:
true
if they are equal,false
otherwise.Source: Core/Matrix4.js, line 2526 -
equalsEpsilon(right, epsilon) → Boolean
-
Compares this matrix to the provided matrix componentwise and returns
true
if they are within the provided epsilon,false
otherwise.Name Type Description right
Matrix4 optional The right hand side matrix. epsilon
Number The epsilon to use for equality testing. Returns:
true
if they are within the provided epsilon,false
otherwise.Source: Core/Matrix4.js, line 2540 -
toString() → String
-
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)'.Source: Core/Matrix4.js, line 2551 -
staticMatrix4.abs(matrix, result) → Matrix4
-
Computes a matrix, which contains the absolute (unsigned) values of the provided matrix's elements.
Name Type Description matrix
Matrix4 The matrix with signed elements. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 1986 -
staticMatrix4.clone(matrix, result) → Matrix4
-
Duplicates a Matrix4 instance.
Name Type Description matrix
Matrix4 The matrix to duplicate. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided. (Returns undefined if matrix is undefined)Source: Core/Matrix4.js, line 179 -
staticMatrix4.computeInfinitePerspectiveOffCenter(left, right, bottom, top, near, far, result)
-
Computes a Matrix4 instance representing an infinite off center perspective transformation.
Name Type Description left
Number The number of meters to the left of the camera that will be in view. right
Number The number of meters to the right of the camera that will be in view. bottom
Number The number of meters below of the camera that will be in view. top
Number The number of meters above of the camera that will be in view. near
Number The distance to the near plane in meters. far
Number The distance to the far plane in meters. result
Matrix4 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 Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 857 -
staticMatrix4.computeOrthographicOffCenter(left, right, bottom, top, near, far, result)
-
Computes a Matrix4 instance representing an orthographic transformation matrix.
Name Type Description left
Number The number of meters to the left of the camera that will be in view. right
Number The number of meters to the right of the camera that will be in view. bottom
Number The number of meters below of the camera that will be in view. top
Number The number of meters above of the camera that will be in view. near
Number The distance to the near plane in meters. far
Number The distance to the far plane in meters. result
Matrix4 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 Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 716 -
staticMatrix4.computePerspectiveFieldOfView(fovY, aspectRatio, near, far, result)
-
Computes a Matrix4 instance representing a perspective transformation matrix.
Name Type Description fovY
Number The field of view along the Y axis in radians. aspectRatio
Number The aspect ratio. near
Number The distance to the near plane in meters. far
Number The distance to the far plane in meters. result
Matrix4 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 Matrix4 instance if one was not provided.Throws:
-
DeveloperError : fovY must be in [0, PI).
-
DeveloperError : aspectRatio must be greater than zero.
-
DeveloperError : near must be greater than zero.
-
DeveloperError : far must be greater than zero.
Source: Core/Matrix4.js, line 651 -
-
staticMatrix4.computePerspectiveOffCenter(left, right, bottom, top, near, far, result)
-
Computes a Matrix4 instance representing an off center perspective transformation.
Name Type Description left
Number The number of meters to the left of the camera that will be in view. right
Number The number of meters to the right of the camera that will be in view. bottom
Number The number of meters below of the camera that will be in view. top
Number The number of meters above of the camera that will be in view. near
Number The distance to the near plane in meters. far
Number The distance to the far plane in meters. result
Matrix4 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 Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 788 -
staticMatrix4.computeViewportTransformation(viewport, nearDepthRange, farDepthRange, result)
-
Computes a Matrix4 instance that transforms from normalized device coordinates to window coordinates.
Name Type Default Description viewport
Object { x : 0.0, y : 0.0, width : 0.0, height : 0.0 }
optional The viewport's corners as shown in Example 1. nearDepthRange
Number 0.0
optional The near plane distance in window coordinates. farDepthRange
Number 1.0
optional The far plane distance in window coordinates. result
Matrix4 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 Matrix4 instance if one was not provided.Example:
// Example 1. Create viewport transformation using an explicit viewport and depth range. var m = Cesium.Matrix4.computeViewportTransformation({ x : 0.0, y : 0.0, width : 1024.0, height : 768.0 }, 0.0, 1.0); // Example 2. Create viewport transformation using the context's viewport. var m = Cesium.Matrix4.computeViewportTransformation(context.getViewport());
See:
Source: Core/Matrix4.js, line 934 -
staticMatrix4.equals(left, right) → Boolean
-
Compares the provided matrices componentwise and returns
true
if they are equal,false
otherwise.Name Type Description left
Matrix4 optional The first matrix. right
Matrix4 optional The second matrix. Returns:
true
if left and right are equal,false
otherwise.Example:
//compares two Matrix4 instances // a = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0] // b = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0] if(Cesium.Matrix4.equals(a,b)) { console.log("Both matrices are equal"); } else { console.log("They are not equal"); } //Prints "Both matrices are equal" on the console
Source: Core/Matrix4.js, line 2051 -
staticMatrix4.equalsEpsilon(left, right, epsilon) → Boolean
-
Compares the provided matrices componentwise and returns
true
if they are within the provided epsilon,false
otherwise.Name Type Description left
Matrix4 optional The first matrix. right
Matrix4 optional The second matrix. epsilon
Number The epsilon to use for equality testing. Returns:
true
if left and right are within the provided epsilon,false
otherwise.Example:
//compares two Matrix4 instances // a = [10.5, 14.5, 18.5, 22.5] // [11.5, 15.5, 19.5, 23.5] // [12.5, 16.5, 20.5, 24.5] // [13.5, 17.5, 21.5, 25.5] // b = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0] if(Cesium.Matrix4.equalsEpsilon(a,b,0.1)){ console.log("Difference between both the matrices is less than 0.1"); } else { console.log("Difference between both the matrices is not less than 0.1"); } //Prints "Difference between both the matrices is not less than 0.1" on the console
Source: Core/Matrix4.js, line 2105 -
staticMatrix4.fromCamera(camera, result)
-
Computes a Matrix4 instance from a Camera.
Name Type Description camera
Camera The camera to use. result
Matrix4 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 Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 550 -
staticMatrix4.fromColumnMajorArray(values, result)
-
Computes a Matrix4 instance from a column-major order array.
Name Type Description values
Number[] The column-major order array. result
Matrix4 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 Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 243 -
staticMatrix4.fromRotationTranslation(rotation, translation, result)
-
Computes a Matrix4 instance from a Matrix3 representing the rotation and a Cartesian3 representing the translation.
Name Type Description rotation
Matrix3 The upper left portion of the matrix representing the rotation. translation
Cartesian3 The upper right portion of the matrix representing the translation. result
Matrix4 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 Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 304 -
staticMatrix4.fromRowMajorArray(values, result)
-
Computes a Matrix4 instance from a row-major order array. The resulting matrix will be in column-major order.
Name Type Description values
Number[] The row-major order array. result
Matrix4 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 Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 262 -
staticMatrix4.fromScale(scale, result)
-
Computes a Matrix4 instance representing a non-uniform scale.
Name Type Description scale
Cartesian3 The x, y, and z scale factors. result
Matrix4 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 Matrix4 instance if one was not provided.Example:
// Creates // [7.0, 0.0, 0.0, 0.0] // [0.0, 8.0, 0.0, 0.0] // [0.0, 0.0, 9.0, 0.0] // [0.0, 0.0, 0.0, 1.0] var m = Cesium.Matrix4.fromScale(new Cartesian3(7.0, 8.0, 9.0));
Source: Core/Matrix4.js, line 455 -
staticMatrix4.fromTranslation(translation, result)
-
Creates a Matrix4 instance from a Cartesian3 representing the translation.
Name Type Description translation
Cartesian3 The upper right portion of the matrix representing the translation. result
Matrix4 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 Matrix4 instance if one was not provided.See:
Source: Core/Matrix4.js, line 435 -
staticMatrix4.fromTranslationQuaternionRotationScale(translation, rotation, scale, result)
-
Computes a Matrix4 instance from a translation, rotation, and scale (TRS) representation with the rotation represented as a quaternion.
Name Type Description translation
Cartesian3 The translation transformation. rotation
Quaternion The rotation transformation. scale
Cartesian3 The non-uniform scale transformation. result
Matrix4 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 Matrix4 instance if one was not provided.Example:
result = Cesium.Matrix4.fromTranslationQuaternionRotationScale( new Cesium.Cartesian3(1.0, 2.0, 3.0), // translation Cesium.Quaternion.IDENTITY, // rotation new Cesium.Cartesian3(7.0, 8.0, 9.0), // scale result);
Source: Core/Matrix4.js, line 361 -
staticMatrix4.fromUniformScale(scale, result)
-
Computes a Matrix4 instance representing a uniform scale.
Name Type Description scale
Number The uniform scale factor. result
Matrix4 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 Matrix4 instance if one was not provided.Example:
// Creates // [2.0, 0.0, 0.0, 0.0] // [0.0, 2.0, 0.0, 0.0] // [0.0, 0.0, 2.0, 0.0] // [0.0, 0.0, 0.0, 1.0] var m = Cesium.Matrix4.fromScale(2.0);
Source: Core/Matrix4.js, line 505 -
staticMatrix4.getColumn(matrix, index, result) → Cartesian4
-
Retrieves a copy of the matrix column at the provided index as a Cartesian4 instance.
Name Type Description matrix
Matrix4 The matrix to use. index
Number The zero-based index of the column to retrieve. result
Cartesian4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian4 instance if one was not provided.Throws:
-
DeveloperError : index must be 0, 1, 2, or 3.
Example:
//returns a Cartesian4 instance with values from the specified column // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0] //Example 1: Creates an instance of Cartesian var a = Cesium.Matrix4.getColumn(m, 2); //Example 2: Sets values for Cartesian instance var a = new Cesium.Cartesian4(); Cesium.Matrix4.getColumn(m, 2, a); // a.x = 12.0; a.y = 16.0; a.z = 20.0; a.w = 24.0;
See:
Source: Core/Matrix4.js, line 1091 -
-
staticMatrix4.getElementIndex(row, column) → Number
-
Computes the array index of the element at the provided row and column.
Name Type Description row
Number The zero-based index of the row. column
Number 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, 1, 2, or 3.
-
DeveloperError : column must be 0, 1, 2, or 3.
Example:
var myMatrix = new Cesium.Matrix4(); var column1Row0Index = Cesium.Matrix4.getElementIndex(1, 0); var column1Row0 = myMatrix[column1Row0Index] myMatrix[column1Row0Index] = 10.0;
Source: Core/Matrix4.js, line 1049 -
-
staticMatrix4.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 in the upper-left 3x3 matrix.
Name Type Description matrix
Matrix4 The matrix. Returns:
The maximum scale.Source: Core/Matrix4.js, line 1312 -
staticMatrix4.getRotation(matrix, result) → Matrix3
-
Gets the upper left 3x3 rotation matrix of the provided matrix, assuming the matrix is a affine transformation matrix.
Name Type Description matrix
Matrix4 The matrix to use. result
Matrix3 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.Example:
// returns a Matrix3 instance from a Matrix4 instance // m = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0] var b = new Cesium.Matrix3(); Cesium.Matrix4.getRotation(m,b); // b = [10.0, 14.0, 18.0] // [11.0, 15.0, 19.0] // [12.0, 16.0, 20.0]
See:
Source: Core/Matrix4.js, line 2184 -
staticMatrix4.getRow(matrix, index, result) → Cartesian4
-
Retrieves a copy of the matrix row at the provided index as a Cartesian4 instance.
Name Type Description matrix
Matrix4 The matrix to use. index
Number The zero-based index of the row to retrieve. result
Cartesian4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian4 instance if one was not provided.Throws:
-
DeveloperError : index must be 0, 1, 2, or 3.
Example:
//returns a Cartesian4 instance with values from the specified column // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0] //Example 1: Returns an instance of Cartesian var a = Cesium.Matrix4.getRow(m, 2); //Example 1: Sets values for a Cartesian instance var a = new Cartesian4(); Cesium.Matrix4.getRow(m, 2, a); // a.x = 18.0; a.y = 19.0; a.z = 20.0; a.w = 21.0;
See:
Source: Core/Matrix4.js, line 1198 -
-
staticMatrix4.getScale(matrix, result) → Cartesian3
-
Extracts the non-uniform scale assuming the matrix is an affine transformation.
Name Type Description matrix
Matrix4 The matrix. result
Cartesian3 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.Source: Core/Matrix4.js, line 1284 -
staticMatrix4.getTranslation(matrix, result) → Cartesian3
-
Gets the translation portion of the provided matrix, assuming the matrix is a affine transformation matrix.
Name Type Description matrix
Matrix4 The matrix to use. result
Cartesian3 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.See:
Source: Core/Matrix4.js, line 2143 -
staticMatrix4.inverse(matrix, result) → Matrix4
-
Computes the inverse of the provided matrix using Cramers Rule. If the determinant is zero, the matrix can not be inverted, and an exception is thrown. If the matrix is an affine transformation matrix, it is more efficient to invert it with
Matrix4.inverseTransformation
.Name Type Description matrix
Matrix4 The matrix to invert. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.Throws:
-
RuntimeError : matrix is not invertible because its determinate is zero.
Source: Core/Matrix4.js, line 2221 -
-
staticMatrix4.inverseTransformation(matrix, result) → Matrix4
-
Computes the inverse of the provided matrix assuming it is an affine transformation matrix, where the upper left 3x3 elements are a rotation matrix, and the upper three elements in the fourth column are the translation. The bottom row is assumed to be [0, 0, 0, 1]. The matrix is not verified to be in the proper form. This method is faster than computing the inverse for a general 4x4 matrix using
Matrix4.inverse
.Name Type Description matrix
Matrix4 The matrix to invert. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.Source: Core/Matrix4.js, line 2346 -
staticMatrix4.multiply(left, right, result) → Matrix4
-
Computes the product of two matrices.
Name Type Description left
Matrix4 The first matrix. right
Matrix4 The second matrix. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Source: Core/Matrix4.js, line 1326 -
staticMatrix4.multiplyByPoint(matrix, cartesian, result) → Cartesian3
-
Computes the product of a matrix and a
Cartesian3
. This is equivalent to callingMatrix4.multiplyByVector
with aCartesian4
with aw
component of 1, but returns aCartesian3
instead of aCartesian4
.Name Type Description matrix
Matrix4 The matrix. cartesian
Cartesian3 The point. result
Cartesian3 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.Example:
var p = new Cesium.Cartesian3(1.0, 2.0, 3.0); Cesium.Matrix4.multiplyByPoint(matrix, p, result);
Source: Core/Matrix4.js, line 1773 -
staticMatrix4.multiplyByPointAsVector(matrix, cartesian, result) → Cartesian3
-
Computes the product of a matrix and a
Cartesian3
. This is equivalent to callingMatrix4.multiplyByVector
with aCartesian4
with aw
component of zero.Name Type Description matrix
Matrix4 The matrix. cartesian
Cartesian3 The point. result
Cartesian3 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided.Example:
var p = new Cesium.Cartesian3(1.0, 2.0, 3.0); Cesium.Matrix4.multiplyByPointAsVector(matrix, p, result); // A shortcut for // Cartesian3 p = ... // Cesium.Matrix4.multiplyByVector(matrix, new Cesium.Cartesian4(p.x, p.y, p.z, 0.0), result);
Source: Core/Matrix4.js, line 1732 -
staticMatrix4.multiplyByScalar(matrix, scalar, result) → Matrix4
-
Computes the product of a matrix and a scalar.
Name Type Description matrix
Matrix4 The matrix. scalar
Number The number to multiply by. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian4 instance if one was not provided.Example:
//create a Matrix4 instance which is a scaled version of the supplied Matrix4 // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0] var a = Cesium.Matrix4.multiplyByScalar(m, -2); // m remains the same // a = [-20.0, -22.0, -24.0, -26.0] // [-28.0, -30.0, -32.0, -34.0] // [-36.0, -38.0, -40.0, -42.0] // [-44.0, -46.0, -48.0, -50.0]
Source: Core/Matrix4.js, line 1825 -
staticMatrix4.multiplyByScale(matrix, scale, result) → Matrix4
-
Multiplies a transformation matrix (with a bottom row of
[0.0, 0.0, 0.0, 1.0]
) by an implicit non-uniform scale matrix. This is an optimization forMatrix4.multiply(m, Matrix4.fromScale(scale), m);
with less allocations and arithmetic operations.Name Type Description matrix
Matrix4 The matrix on the left-hand side. scale
Cartesian3 The non-uniform scale on the right-hand side. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Example:
// Instead of Matrix4.multiply(m, Cesium.Matrix4.fromScale(scale), m); Cesium.Matrix4.multiplyByUniformScale(m, scale, m);
See:
Source: Core/Matrix4.js, line 1630 -
staticMatrix4.multiplyByTranslation(matrix, translation, result) → Matrix4
-
Multiplies a transformation matrix (with a bottom row of
[0.0, 0.0, 0.0, 1.0]
) by an implicit translation matrix defined by aCartesian3
. This is an optimization forMatrix4.multiply(m, Matrix4.fromTranslation(position), m);
with less allocations and arithmetic operations.Name Type Description matrix
Matrix4 The matrix on the left-hand side. translation
Cartesian3 The translation on the right-hand side. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Example:
// Instead of Matrix4.multiply(m, Cesium.Matrix4.fromTranslation(position), m); Cesium.Matrix4.multiplyByTranslation(m, position, m);
See:
Source: Core/Matrix4.js, line 1531 -
staticMatrix4.multiplyByUniformScale(matrix, scale, result) → Matrix4
-
Multiplies a transformation matrix (with a bottom row of
[0.0, 0.0, 0.0, 1.0]
) by an implicit uniform scale matrix. This is an optimization forMatrix4.multiply(m, Matrix4.fromUniformScale(scale), m);
with less allocations and arithmetic operations.Name Type Description matrix
Matrix4 The matrix on the left-hand side. scale
Number The uniform scale on the right-hand side. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Example:
// Instead of Matrix4.multiply(m, Cesium.Matrix4.fromUniformScale(scale), m); Cesium.Matrix4.multiplyByUniformScale(m, scale, m);
See:
Source: Core/Matrix4.js, line 1597 -
staticMatrix4.multiplyByVector(matrix, cartesian, result) → Cartesian4
-
Computes the product of a matrix and a column vector.
Name Type Description matrix
Matrix4 The matrix. cartesian
Cartesian4 The vector. result
Cartesian4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Cartesian4 instance if one was not provided.Source: Core/Matrix4.js, line 1685 -
staticMatrix4.multiplyTransformation(left, right, result) → Matrix4
-
Computes the product of two matrices assuming the matrices are affine transformation matrices, where the upper left 3x3 elements are a rotation matrix, and the upper three elements in the fourth column are the translation. The bottom row is assumed to be [0, 0, 0, 1]. The matrix is not verified to be in the proper form. This method is faster than computing the product for general 4x4 matrices using
Matrix4.multiply
.Name Type Description left
Matrix4 The first matrix. right
Matrix4 The second matrix. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Example:
var m1 = new Cesium.Matrix4(1.0, 6.0, 7.0, 0.0, 2.0, 5.0, 8.0, 0.0, 3.0, 4.0, 9.0, 0.0, 0.0, 0.0, 0.0, 1.0]; var m2 = Cesium.Transforms.eastNorthUpToFixedFrame(new Cesium.Cartesian3(1.0, 1.0, 1.0)); var m3 = Cesium.Matrix4.multiplyTransformation(m1, m2);
Source: Core/Matrix4.js, line 1435 -
staticMatrix4.negate(matrix, result) → Matrix4
-
Computes a negated copy of the provided matrix.
Name Type Description matrix
Matrix4 The matrix to negate. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Example:
//create a new Matrix4 instance which is a negation of a Matrix4 // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0] var a = Cesium.Matrix4.negate(m); // m remains the same // a = [-10.0, -11.0, -12.0, -13.0] // [-14.0, -15.0, -16.0, -17.0] // [-18.0, -19.0, -20.0, -21.0] // [-22.0, -23.0, -24.0, -25.0]
Source: Core/Matrix4.js, line 1883 -
staticMatrix4.pack(value, array, startingIndex)
-
Stores the provided instance into the provided array.
Name Type Default Description value
Matrix4 The value to pack. array
Number[] The array to pack into. startingIndex
Number 0
optional The index into the array at which to start packing the elements. Source: Core/Matrix4.js, line 100 -
staticMatrix4.setColumn(matrix, index, cartesian, result) → Matrix4
-
Computes a new matrix that replaces the specified column in the provided matrix with the provided Cartesian4 instance.
Name Type Description matrix
Matrix4 The matrix to use. index
Number The zero-based index of the column to set. cartesian
Cartesian4 The Cartesian whose values will be assigned to the specified column. result
Cartesian4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Throws:
-
DeveloperError : index must be 0, 1, 2, or 3.
Example:
//creates a new Matrix4 instance with new column values from the Cartesian4 instance // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0] var a = Cesium.Matrix4.setColumn(m, 2, new Cartesian4(99.0, 98.0, 97.0, 96.0)); // m remains the same // a = [10.0, 11.0, 99.0, 13.0] // [14.0, 15.0, 98.0, 17.0] // [18.0, 19.0, 97.0, 21.0] // [22.0, 23.0, 96.0, 25.0]
See:
Source: Core/Matrix4.js, line 1147 -
-
staticMatrix4.setRow(matrix, index, cartesian, result) → Matrix4
-
Computes a new matrix that replaces the specified row in the provided matrix with the provided Cartesian4 instance.
Name Type Description matrix
Matrix4 The matrix to use. index
Number The zero-based index of the row to set. cartesian
Cartesian4 The Cartesian whose values will be assigned to the specified row. result
Cartesian4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Throws:
-
DeveloperError : index must be 0, 1, 2, or 3.
Example:
//create a new Matrix4 instance with new row values from the Cartesian4 instance // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0] var a = Cesium.Matrix4.setRow(m, 2, new Cartesian4(99.0, 98.0, 97.0, 96.0)); // m remains the same // a = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [99.0, 98.0, 97.0, 96.0] // [22.0, 23.0, 24.0, 25.0]
See:
Source: Core/Matrix4.js, line 1253 -
-
staticMatrix4.toArray(matrix, result) → Number[]
-
Computes an Array from the provided Matrix4 instance. The array will be in column-major order.
Name Type Description matrix
Matrix4 The matrix to use.. result
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.Example:
//create an array from an instance of Matrix4 // m = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0] var a = Cesium.Matrix4.toArray(m); // m remains the same //creates a = [10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0]
Source: Core/Matrix4.js, line 1000 -
staticMatrix4.transpose(matrix, result) → Matrix4
-
Computes the transpose of the provided matrix.
Name Type Description matrix
Matrix4 The matrix to transpose. result
Matrix4 optional The object onto which to store the result. Returns:
The modified result parameter or a new Matrix4 instance if one was not provided.Example:
//returns transpose of a Matrix4 // m = [10.0, 11.0, 12.0, 13.0] // [14.0, 15.0, 16.0, 17.0] // [18.0, 19.0, 20.0, 21.0] // [22.0, 23.0, 24.0, 25.0] var a = Cesium.Matrix4.negate(m); // m remains the same // a = [10.0, 14.0, 18.0, 22.0] // [11.0, 15.0, 19.0, 23.0] // [12.0, 16.0, 20.0, 24.0] // [13.0, 17.0, 21.0, 25.0]
Source: Core/Matrix4.js, line 1938 -
staticMatrix4.unpack(array, startingIndex, result)
-
Retrieves an instance from a packed array.
Name Type Default Description array
Number[] The packed array. startingIndex
Number 0
optional The starting index of the element to be unpacked. result
Matrix4 optional The object into which to store the result. Source: Core/Matrix4.js, line 139