new Matrix4(column0Row0, column1Row0, column2Row0, column3Row0, column0Row1, column1Row1, column2Row1, column3Row1, column0Row2, column1Row2, column2Row2, column3Row2, column0Row3, column1Row3, column2Row3, column3Row3)
A 4x4 matrix that can be indexed in column first order. For ease of code reading, constructor parameters are arranged in line priority order.
| Name | Type | Default | Description |
|---|---|---|---|
column0Row0 |
Number | 0.0 |
optional
The value of column 0 and row 0. |
column1Row0 |
Number | 0.0 |
optional
The value in column 1, row 0. |
column2Row0 |
Number | 0.0 |
optional
The value in column 2, row 0. |
column3Row0 |
Number | 0.0 |
optional
The value in column 3, row 0. |
column0Row1 |
Number | 0.0 |
optional
The value of column 0 and row 1. |
column1Row1 |
Number | 0.0 |
optional
The value in the first row of the first column. |
column2Row1 |
Number | 0.0 |
optional
The value in the first row of the second column. |
column3Row1 |
Number | 0.0 |
optional
The value in the first row of the third column. |
column0Row2 |
Number | 0.0 |
optional
The value in column 0, row 2. |
column1Row2 |
Number | 0.0 |
optional
The value in the second row of the first column. |
column2Row2 |
Number | 0.0 |
optional
The value in the second row of the second column. |
column3Row2 |
Number | 0.0 |
optional
The value in the second row of the third column. |
column0Row3 |
Number | 0.0 |
optional
The value in column 0, row 3. |
column1Row3 |
Number | 0.0 |
optional
The value in the third row of the first column. |
column2Row3 |
Number | 0.0 |
optional
The value in the second column and third row. |
column3Row3 |
Number | 0.0 |
optional
The value in the third column and third row. |
- See:
-
- Matrix4.fromColumnMajorArray
- Matrix4.fromRowMajorArray
- Matrix4.fromRotationTranslation
- Matrix4.fromTranslationRotationScale
- Matrix4.fromTranslationQuaternionRotationScale
- Matrix4.fromTranslation
- Matrix4.fromScale
- Matrix4.fromUniformScale
- Matrix4.fromCamera
- Matrix4.computePerspectiveFieldOfView
- Matrix4.computeOrthographicOffCenter
- Matrix4.computePerspectiveOffCenter
- Matrix4.computeInfinitePerspectiveOffCenter
- Matrix4.computeViewportTransformation
- Matrix4.computeView
- Matrix2
- Matrix3
- Packable
Members
-
lengthNumber
-
The number of elements used to package objects into an array.
-
(static, constant) COLUMN0ROW0Number
-
The index of column 0 and row 0 in Matrix4.
-
(static, constant) COLUMN0ROW1Number
-
The index into Matrix4 for column 0, row 1.
-
(static, constant) COLUMN0ROW2Number
-
The index of column 0 and row 1 in Matrix4.
-
(static, constant) COLUMN0ROW3Number
-
The index of column 0 and row 3 in Matrix4.
-
(static, constant) COLUMN1ROW0Number
-
The index of column 1 and row 0 in Matrix4.
-
(static, constant) COLUMN1ROW1Number
-
Matrix4 index in column 1, row 1.
-
(static, constant) COLUMN1ROW2Number
-
Matrix4 index in column 1, row 2.
-
(static, constant) COLUMN1ROW3Number
-
Matrix4 index in column 1, row 3.
-
(static, constant) COLUMN2ROW0Number
-
The index of column 2 and row 0 in Matrix4.
-
(static, constant) COLUMN2ROW1Number
-
Matrix4 index in column 2, row 1.
-
(static, constant) COLUMN2ROW2Number
-
Matrix4 index in column 2, row 2.
-
(static, constant) COLUMN2ROW3Number
-
Matrix4 index in column 2, row 3.
-
(static, constant) COLUMN3ROW0Number
-
The index into Matrix4 for column 3, row 0.
-
(static, constant) COLUMN3ROW1Number
-
The index of column 3 and row 0 in Matrix4.
-
(static, constant) COLUMN3ROW2Number
-
Matrix4 index in column 3, row 2.
-
(static, constant) COLUMN3ROW3Number
-
Matrix4 index in column 3, row 3.
-
(static, constant) ConvertNDCToHalfZRangeNumber
-
This matrix is used to transform the Z-coordinate of NDC from -1 to 1 to 0 to 1
-
static halfZRange
-
Is the NDC coordinate range from 0 to 1. True on WebGPU, false on WebGL
-
(static, constant) IDENTITYMatrix4
-
Initialize an immutable Matrix4 instance as an identity matrix.
-
static packedLengthNumber
-
The number of elements used to package objects into an array.
-
(static, constant) ZEROMatrix4
-
Initialize an immutable Matrix4 instance to a zero matrix.
Methods
-
clone(result){Matrix4}
-
Copy the provided Matrix4 instance.
Name Type Description resultMatrix4 optional The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters or a new Matrix4 instance (if not provided). -
equals(right){Boolean}
-
Compare this matrix with the provided matrix, return true if they are equal, otherwise return false.
Name Type Description rightMatrix4 optional Right hand matrix.
Returns:
Type Description Boolean If they are equal, it is true; otherwise, it is false. -
equalsEpsilon(right, epsilon){Boolean}
-
Compare this matrix with the provided matrix by component, return true if they are within the provided epsilon, otherwise return false.
Name Type Description rightMatrix4 optional Right hand matrix.
epsilonNumber The epsilon used for equality testing.
Returns:
Type Description Boolean If they are within the provided epsilon, it is true; otherwise, it is false. -
toString(){String}
-
Calculate the string representing this matrix, with each row on a separate row, in the format of '(column0, column1, column2, column3)'.
Returns:
Type Description String The string representing the provided matrix, with each row on a separate row, in the format of '(column0, column1, column2, column3)'. -
static abs(matrix, result){Matrix4}
-
Calculate a matrix that contains the absolute (unsigned) values of the provided matrix elements.
Name Type Description matrixMatrix4 A matrix with symbolic elements.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static add(left, right, result){Matrix4}
-
Calculate the sum of two matrices.
Name Type Description leftMatrix4 The first matrix.
rightMatrix4 The second matrix.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static clone(matrix, result){Matrix4}
-
Copy a Matrix4 instance.
Name Type Description matrixMatrix4 The matrix to be copied.
resultMatrix4 optional The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters or a new Matrix4 instance (if not provided). If the matrix is undefined, return undefined -
static computeInfinitePerspectiveOffCenter(left, right, bottom, top, near, result){Matrix4}
-
Compute a Matrix4 instance representing an infinite off center perspective transformation.
Name Type Description leftNumber Measure the distance to the left of the camera in the field of view.
rightNumber The number of meters to the right of the camera in the field of view.
bottomNumber The number of meters below the camera in the field of view.
topNumber The number of meters above the camera in the field of view.
nearNumber The distance to the near plane (in meters).
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static computeOrthographicOffCenter(left, right, bottom, top, near, far, result){Matrix4}
-
Compute a Matrix4 instance representing an orthogonal transformation matrix.
Name Type Description leftNumber Measure the distance to the left of the camera in the field of view.
rightNumber The number of meters to the right of the camera in the field of view.
bottomNumber The number of meters below the camera in the field of view.
topNumber The number of meters above the camera in the field of view.
nearNumber The distance to the near plane (in meters).
farNumber The distance to the far plane (in meters).
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static computePerspectiveFieldOfView(fovY, aspectRatio, near, far, result){Matrix4}
-
Compute a Matrix4 instance representing a perspective transformation matrix.
Name Type Description fovYNumber View along the Y-axis (in radians).
aspectRatioNumber Aspect ratio.
nearNumber The distance to the near plane (in meters).
farNumber The distance to the far plane (in meters).
resultMatrix4 The object that stores the results.
Throws:
-
-
FovY must be in (0, PI].
- Type
- DeveloperError
-
-
-
The aspectRatio must be greater than zero.
- Type
- DeveloperError
-
-
-
Near must be greater than zero.
- Type
- DeveloperError
-
-
-
Far must be greater than zero.
- Type
- DeveloperError
-
Returns:
Type Description Matrix4 The modified result parameters. -
-
static computePerspectiveOffCenter(left, right, bottom, top, near, far, result){Matrix4}
-
Calculate a Matrix4 instance representing a perspective transformation that deviates from the center.
Name Type Description leftNumber Measure the distance to the left of the camera in the field of view.
rightNumber The number of meters to the right of the camera in the field of view.
bottomNumber The number of meters below the camera in the field of view.
topNumber The number of meters above the camera in the field of view.
nearNumber The distance to the near plane (in meters).
farNumber The distance to the far plane (in meters).
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static computeView(position, direction, up, right, result){Matrix4}
-
Compute Matrix4 instances that convert from geographic space to view space.
Name Type Description positionCartesian3 The position of the camera.
directionCartesian3 The direction of progress.
upCartesian3 Upward direction.
rightCartesian3 The correct direction.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static computeViewportTransformation(viewport, nearDepthRange, farDepthRange, result){Matrix4}
-
Compute Matrix4 instances that convert standardized device coordinates to window coordinates.
Name Type Default Description viewportObject {x: 0.0, y: 0.0, width: 0.0, height: 0.0} optional The angle of the viewport, as shown in Example 1.
nearDepthRangeNumber 0.0 optional Near plane distance in window coordinates.
farDepthRangeNumber 1.0 optional Distance from the far plane in the window coordinates.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. Example
// Create viewport transformation using an explicit viewport and depth range. var m = SuperMap3D.Matrix4.computeViewportTransformation({ x : 0.0, y : 0.0, width : 1024.0, height : 768.0 }, 0.0, 1.0, new SuperMap3D.Matrix4()); -
static equals(left, right){Boolean}
-
Compare the provided matrices one by one, return true if they are equal, otherwise return false.
Name Type Description leftMatrix4 optional The first matrix.
rightMatrix4 optional The second matrix.
Returns:
Type Description Boolean If they are equal, it is true; otherwise, it is false. 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(SuperMap3D.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 -
static equalsEpsilon(left, right, epsilon){Boolean}
-
Compare the provided matrices one by one, return true if they are within the provided epsilon, otherwise return false.
Name Type Description leftMatrix4 optional The first matrix.
rightMatrix4 optional The second matrix.
epsilonNumber Epsilon used for equality testing
Returns:
Type Description Boolean If it is within the provided epsilon, it is true; otherwise, it is false. 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(SuperMap3D.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 -
static fromArray(array, startingIndex, result){Matrix4}
-
Create Matrix4 using 16 consecutive elements from an array.
Name Type Default Description arrayArray.<Number> An array of 16 consecutive elements corresponding to matrix positions. Assuming column priority order.
startingIndexNumber 0 optional The offset of the first element in the array corresponds to the position of the first column and first row in the matrix.
resultMatrix4 optional The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters or a new Matrix4 instance (if not provided). 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 = SuperMap3D.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 = SuperMap3D.Matrix4.fromArray(v2, 2); -
static fromCamera(camera, result){Matrix4}
-
Calculate Matrix4 instances from the camera.
Name Type Description cameraCamera The camera to be used.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 If the modified result parameters are not provided, they will be the new Matrix4 instance. -
static fromColumnMajorArray(values, result){Matrix4}
-
Compute Matrix4 instances from the column main order array.
Name Type Description valuesArray.<Number> Column main order array.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 If the modified result parameters are not provided, they will be the new Matrix4 instance. -
static fromRotationTranslation(rotation, translation, result){Matrix4}
-
Calculate Matrix4 instances from Matrix3 representing rotation and Cartesian3 representing translation.
Name Type Default Description rotationMatrix3 The upper left part of the matrix representing rotation.
translationCartesian3 Cartesian3.ZERO optional The upper right part of the matrix representing translation.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 If the modified result parameters are not provided, they will be the new Matrix4 instance. -
static fromRowMajorArray(values, result){Matrix4}
-
Compute Matrix4 instances from the main sequential array of rows. The generated matrix will be arranged in column priority order.
Name Type Description valuesArray.<Number> Row main sequence array.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 The modified result parameters, or a new Matrix4 instance (if not provided). -
static fromScale(scale, result){Matrix4}
-
Calculate a Matrix4 instance that represents non-uniform proportions.
Name Type Description scaleCartesian3 x. Y and Z scaling factors.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 If the modified result parameters are not provided, they will be the new Matrix4 instance. 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 = SuperMap3D.Matrix4.fromScale(new SuperMap3D.Cartesian3(7.0, 8.0, 9.0)); -
static fromTranslation(translation, result){Matrix4}
-
Create a Matrix4 instance from Cartesian3 representing translation.
Name Type Description translationCartesian3 The upper right part of the matrix represents translation.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 The modified result parameters, or a new Matrix4 instance (if not provided). -
static fromTranslationQuaternionRotationScale(translation, rotation, scale, result){Matrix4}
-
Compute Matrix4 instances from translation, rotation, and scaling (TRS) representations, with rotation represented as quaternions.
Name Type Description translationCartesian3 transformation.
rotationQuaternion Rotation transformation.
scaleCartesian3 Non uniform proportional transformation.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 The modified result parameters, or a new Matrix4 instance (if not provided). Example
var result = SuperMap3D.Matrix4.fromTranslationQuaternionRotationScale( new SuperMap3D.Cartesian3(1.0, 2.0, 3.0), // translation SuperMap3D.Quaternion.IDENTITY, // rotation new SuperMap3D.Cartesian3(7.0, 8.0, 9.0), // scale result); -
static fromTranslationRotationScale(translationRotationScale, result){Matrix4}
-
Create a Matrix4 instance from TranslationRotationScale.
Name Type Description translationRotationScaleTranslationRotationScale instance.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 If the modified result parameters are not provided, they will be the new Matrix4 instance. -
static fromUniformScale(scale, result){Matrix4}
-
Calculate a Matrix4 instance that represents a uniform proportion.
Name Type Description scaleNumber Unified scaling factor.
resultMatrix4 optional If the object for storing results is undefined, a new instance will be created.
Returns:
Type Description Matrix4 If the modified result parameters are not provided, they will be the new Matrix4 instance. 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 = SuperMap3D.Matrix4.fromUniformScale(2.0); -
static getColumn(matrix, index, result){Cartesian4}
-
Retrieve a copy of the matrix column at the provided index as a Cartesian4 instance.
Name Type Description matrixMatrix4 The matrix to be used
indexNumber The zero index of the column to be retrieved.
resultCartesian4 The object that stores the results.
Throws:
-
The index must be 0, 1, 2, or 3.
- Type
- DeveloperError
Returns:
Type Description Cartesian4 The modified result parameters. Examples
//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 = SuperMap3D.Matrix4.getColumn(m, 2, new SuperMap3D.Cartesian4());//Example 2: Sets values for Cartesian instance var a = new SuperMap3D.Cartesian4(); SuperMap3D.Matrix4.getColumn(m, 2, a); // a.x = 12.0; a.y = 16.0; a.z = 20.0; a.w = 24.0; -
-
static getElementIndex(row, column){Number}
-
Calculate the array index of the elements in the rows and columns provided.
Name Type Description rowNumber Zero based index of rows.
columnNumber Zero based index of the column.
Throws:
-
-
The row must be 0, 1, 2, or 3.
- Type
- DeveloperError
-
-
-
The column must be 0, 1, 2, or 3.
- Type
- DeveloperError
-
Returns:
Type Description Number The index of the elements on the provided rows and columns. Example
var myMatrix = new SuperMap3D.Matrix4(); var column1Row0Index = SuperMap3D.Matrix4.getElementIndex(1, 0); var column1Row0 = myMatrix[column1Row0Index]; myMatrix[column1Row0Index] = 10.0; -
-
static getMaximumScale(matrix){Number}
-
Assuming the matrix is an affine transformation, calculate the maximum scale. The maximum scale is the maximum length of the column vectors in the 3x3 matrix in the upper left corner. The maximum length of a 3x3 matrix.
Name Type Description matrixMatrix4 Matrix.
Returns:
Type Description Number Maximum proportion. -
static getRotation(matrix, result){Matrix3}
-
Assuming the matrix is an affine transformation, extract the rotation matrix.
Name Type Description matrixMatrix4 The matrix to be used.
resultMatrix3 The object that stores the results.
Returns:
Type Description Matrix3 The modified result parameters. 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 SuperMap3D.Matrix3(); SuperMap3D.Matrix4.getRotation(m,b); // b = [10.0, 14.0, 18.0] // [11.0, 15.0, 19.0] // [12.0, 16.0, 20.0] -
static getRow(matrix, index, result){Cartesian4}
-
Retrieve a copy of the matrix row at the provided index as a Cartesian4 instance.
Name Type Description matrixMatrix4 The matrix to be used.
indexNumber The zero based index of the row to be retrieved.
resultCartesian4 The object that stores the results.
Throws:
-
The index must be 0, 1, 2, or 3.
- Type
- DeveloperError
Returns:
Type Description Cartesian4 The modified result parameters. Examples
//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 = SuperMap3D.Matrix4.getRow(m, 2, new SuperMap3D.Cartesian4());//Example 2: Sets values for a Cartesian instance var a = new SuperMap3D.Cartesian4(); SuperMap3D.Matrix4.getRow(m, 2, a); // a.x = 18.0; a.y = 19.0; a.z = 20.0; a.w = 21.0; -
-
static getScale(matrix, result){Cartesian3}
-
Assuming the matrix is an affine transformation, extract non-uniform proportions.
Name Type Description matrixMatrix4 Matrix.
resultCartesian3 The object that stores the results.
Returns:
Type Description Cartesian3 The modified result parameters. -
static getTranslation(matrix, result){Cartesian3}
-
Assuming the matrix is an affine transformation matrix, obtain the translated part of the provided matrix.
Name Type Description matrixMatrix4 The matrix to be used.
resultCartesian3 The object that stores the results.
Returns:
Type Description Cartesian3 The modified result parameters. -
static inverse(matrix, result){Matrix4}
-
Calculate the inverse matrix of the provided matrix using Cramers' rule. If the determinant is zero, the matrix cannot be reversed and an exception is thrown. If the matrix is an appropriate rigid transformation, using Matrix4. inverteTransformation for inversion will be more effective.
Name Type Description matrixMatrix4 The matrix to be reversed.
resultMatrix4 The object that stores the results.
Throws:
-
A matrix is irreversible because its determinant is zero.
- Type
- RuntimeError
Returns:
Type Description Matrix4 The modified result parameters. -
-
static inverseTransformation(matrix, result){Matrix4}
-
Calculate the inverse of the provided matrix, assuming it is an appropriate rigid matrix, where the 3x3 elements in the upper left corner are rotation matrices and the top three elements in the fourth column are translation matrices. Assuming the bottom row is [0,0,0,1]. The form of the matrix has not been verified to be correct. This method is faster than using Matrix4. inverse to calculate the inverse of a typical 4x4 matrix.
Name Type Description matrixMatrix4 The matrix to be reversed.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static multiply(left, right, result){Matrix4}
-
Calculate the product of two matrices.
Name Type Description leftMatrix4 The first matrix.
rightMatrix4 The second matrix.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static multiplyByMatrix3(matrix, rotation, result){Matrix4}
-
Multiply the transformation matrix (base rows [0.0, 0.0, 0.0, 1.0]) by a 3x3 rotation matrix. This is for Matrix4. multiply (m, Matrix4. from Rotation Translation (rotation), m); Optimization of. Less allocation and arithmetic operations.
Name Type Description matrixMatrix4 Left hand matrix.
rotationMatrix3 Right hand 3x3 rotation matrix.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. Example
// Instead of SuperMap3D.Matrix4.multiply(m, SuperMap3D.Matrix4.fromRotationTranslation(rotation), m); SuperMap3D.Matrix4.multiplyByMatrix3(m, rotation, m); -
static multiplyByPoint(matrix, cartesian, result){Cartesian3}
-
Calculate the product of the matrix and Cartesian3. This is equivalent to calling Cartesian4w using Matrix4. multilyByVector with w component 1, but returning Cartesian3 instead of Cartesian4.
Name Type Description matrixMatrix4 Matrix.
cartesianCartesian3 a key.
resultCartesian3 The object that stores the results.
Returns:
Type Description Cartesian3 The modified result parameters. Example
var p = new SuperMap3D.Cartesian3(1.0, 2.0, 3.0); var result = SuperMap3D.Matrix4.multiplyByPoint(matrix, p, new SuperMap3D.Cartesian3()); -
static multiplyByPointAsVector(matrix, cartesian, result){Cartesian3}
-
Calculate the product of the matrix and Cartesian3. This is equivalent to calling w using Cartesian4 with zero w component.
Name Type Description matrixMatrix4 Matrix.
cartesianCartesian3 The numerical value to be multiplied.
resultCartesian3 The object that stores the results.
Returns:
Type Description Cartesian3 The modified result parameters. Example
var p = new SuperMap3D.Cartesian3(1.0, 2.0, 3.0); var result = SuperMap3D.Matrix4.multiplyByPointAsVector(matrix, p, new SuperMap3D.Cartesian3()); // A shortcut for // Cartesian3 p = ... // SuperMap3D.Matrix4.multiplyByVector(matrix, new SuperMap3D.Cartesian4(p.x, p.y, p.z, 0.0), result); -
static multiplyByScalar(matrix, scalar, result){Matrix4}
-
Calculate the product of a matrix and a scalar.
Name Type Description matrixMatrix4 Matrix.
scalarNumber The numerical value to be multiplied.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. 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 = SuperMap3D.Matrix4.multiplyByScalar(m, -2, new SuperMap3D.Matrix4()); // 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] -
static multiplyByScale(matrix, scale, result){Matrix4}
-
Multiply the affine transformation matrix (base rows [0.0, 0.0, 0.0, 1.0]) by the implicit non-uniform scaling matrix. This is an optimization of Matrix4. multiply (m, Matrix4. from UniformScale, m). Among them, m must be an affine matrix. This function performs fewer allocation and arithmetic operations.
Name Type Description matrixMatrix4 The affine matrix of the left hand.
scaleCartesian3 Non uniform proportion of the right hand.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. Example
// Instead of SuperMap3D.Matrix4.multiply(m, SuperMap3D.Matrix4.fromScale(scale), m); SuperMap3D.Matrix4.multiplyByScale(m, scale, m); -
static multiplyByTranslation(matrix, translation, result){Matrix4}
-
Multiply the transformation matrix (base rows [0.0, 0.0, 0.0, 1.0]) by the implicit translation matrix defined by Cartesian3. This is for Matrix4. multiple (m, Matrix4. from Translation (position), m); Optimization of. Less allocation and arithmetic operations.
Name Type Description matrixMatrix4 Left hand matrix.
translationCartesian3 Translation on the right
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. Example
// Instead of SuperMap3D.Matrix4.multiply(m, SuperMap3D.Matrix4.fromTranslation(position), m); SuperMap3D.Matrix4.multiplyByTranslation(m, position, m); -
static multiplyByUniformScale(matrix, scale, result){Matrix4}
-
Multiply the affine transformation matrix (base rows [0.0, 0.0, 0.0, 1.0]) with the implicit unified proportional matrix. multiply(m,Matrix4.fromUniformScale(scale),m); , where m must be an affine matrix. This function performs fewer allocation and arithmetic operations.
Name Type Description matrixMatrix4 Left hand affine matrix.
scaleNumber The uniform proportion of the right hand.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. Example
// Instead of SuperMap3D.Matrix4.multiply(m, SuperMap3D.Matrix4.fromUniformScale(scale), m); SuperMap3D.Matrix4.multiplyByUniformScale(m, scale, m); -
static multiplyByVector(matrix, cartesian, result){Cartesian4}
-
Calculate the product of matrix and column vectors.
Name Type Description matrixMatrix4 Matrix.
cartesianCartesian4 Vector.
resultCartesian4 The object that stores the results.
Returns:
Type Description Cartesian4 The modified result parameters. -
static multiplyTransformation(left, right, result){Matrix4}
-
Calculate the product of two matrices, assuming the matrix is an affine transformation matrix, where the 3x3 elements in the upper left corner are arbitrary matrices, and the top three elements in the fourth column are translations. Assuming the bottom row is [0,0,0,1]. The form of the matrix has not been verified to be correct. This method is faster than using Matrix4. multiply to calculate the product of a typical 4x4 matrix.
Name Type Description leftMatrix4 The first matrix.
rightMatrix4 The second matrix.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. Example
var m1 = new SuperMap3D.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 = SuperMap3D.Transforms.eastNorthUpToFixedFrame(new SuperMap3D.Cartesian3(1.0, 1.0, 1.0)); var m3 = SuperMap3D.Matrix4.multiplyTransformation(m1, m2, new SuperMap3D.Matrix4()); -
static negate(matrix, result){Matrix4}
-
Calculate the negative copy of the provided matrix.
Name Type Description matrixMatrix4 The matrix to be negated.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. 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 = SuperMap3D.Matrix4.negate(m, new SuperMap3D.Matrix4()); // 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] -
static pack(value, array, startingIndex){Array.<Number>}
-
Store the provided instance in the provided array.
Name Type Default Description valueMatrix4 The value to be packaged.
arrayArray.<Number> The array to be packaged.
startingIndexNumber 0 optional Start packaging the array index of elements.
Returns:
Type Description Array.<Number> The loaded array. -
static setColumn(matrix, index, cartesian, result){Matrix4}
-
Calculate a new matrix and replace the specified columns in the provided matrix with the provided Cartesian4 instance.
Name Type Description matrixMatrix4 The matrix to be used.
indexNumber The zero index of the column to be set.
cartesianCartesian4 Its value will be assigned to the Cartesian of the specified column.
resultMatrix4 The object that stores the results.
Throws:
-
The index must be 0, 1, 2, or 3.
- Type
- DeveloperError
Returns:
Type Description Matrix4 The modified result parameters. 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 = SuperMap3D.Matrix4.setColumn(m, 2, new SuperMap3D.Cartesian4(99.0, 98.0, 97.0, 96.0), new SuperMap3D.Matrix4()); // 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] -
-
static setRow(matrix, index, cartesian, result){Matrix4}
-
Compute a new matrix and replace the specified rows in the provided matrix with the provided Cartesian4 instance.
Name Type Description matrixMatrix4 The matrix to be used.
indexNumber The zero based index of the row to be set.
cartesianCartesian4 Its value will be assigned to the Cartesian of the specified row.
resultMatrix4 The object that stores the results.
Throws:
-
The index must be 0, 1, 2, or 3.
- Type
- DeveloperError
Returns:
Type Description Matrix4 The modified result parameters. 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 = SuperMap3D.Matrix4.setRow(m, 2, new SuperMap3D.Cartesian4(99.0, 98.0, 97.0, 96.0), new SuperMap3D.Matrix4()); // 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] -
-
static setTranslation(matrix, translation, result){Matrix4}
-
Calculate a new matrix and replace the translation in the rightmost column with the provided translation. This assumes that the matrix is an affine transformation.
Name Type Description matrixMatrix4 The matrix to be used.
translationCartesian3 替换所提供矩阵的平移量。
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static subtract(left, right, result){Matrix4}
-
Calculate the difference between two matrices.
Name Type Description leftMatrix4 The first matrix.
rightMatrix4 The second matrix.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. -
static toArray(matrix, result){Array.<Number>}
-
Compute an array from the provided Matrix4 instance. This array will be arranged in column priority order.
Name Type Description matrixMatrix4 The matrix to be used.
resultArray.<Number> optional An array for storing results.
Returns:
Type Description Array.<Number> Modified Array parameters or new Array instances (if 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 = SuperMap3D.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] -
static transpose(matrix, result){Matrix4}
-
Calculate the transpose of the provided matrix.
Name Type Description matrixMatrix4 The matrix to be transposed.
resultMatrix4 The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters. 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 = SuperMap3D.Matrix4.transpose(m, new SuperMap3D.Matrix4()); // 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] -
static unpack(array, startingIndex, result){Matrix4}
-
Retrieve instances from the packaged array.
Name Type Default Description arrayArray.<Number> Packaged array.
startingIndexNumber 0 optional The starting index of the element to be unpacked.
resultMatrix4 optional The object that stores the results.
Returns:
Type Description Matrix4 The modified result parameters or a new Matrix4 instance (if not provided).