[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGeMatrix3d
Class: McGeMatrix3d
2d.McGeMatrix3d
Representing a three-dimensional matrix object
Table of contents
Constructors
Properties
Methods
- angleXYPlane
- clone
- copy
- det
- getData
- invert
- isEqualTo
- isSingular
- postMultBy
- preMultBy
- scale
- setCoordSystem
- setData
- setMirror
- setToIdentity
- setToProduct
- setToRotation
- setToScaling
- setToTranslation
- transposeIt
Constructors
constructor
• new McGeMatrix3d(imp?
)
Constructor.
Parameters
Name | Type | Description |
---|---|---|
imp? | ` Object | Internal implementation object |
Example
import { McGeMatrix3d } from "mxcad"
const matrix = new McGeMatrix3d()
Properties
imp
• imp: any
Internal implementation object
kIdentity
▪ Static
kIdentity: McGeMatrix3d
The identity matrix of multiplication
Methods
angleXYPlane
▸ angleXYPlane(): number
Obtain the rotation angle factor of the matrix in the XY plane. @Returns rotation angle factor.
Returns
number
Example
___
### clone
▸ **clone**(): [`McGeMatrix3d`](2d.McGeMatrix3d.md)
Create a three-dimensional matrix object for Kelon
#### Returns
[`McGeMatrix3d`](2d.McGeMatrix3d.md)
3D matrix object
**`Example`**
```ts
//Matrix1 is a three-dimensional matrix object
const matrix = matrix1.clone()
copy
▸ copy(val
): McGeMatrix3d
Copy the value of the object
Parameters
Name | Type | Description |
---|---|---|
Val | [McGeMatrix3d] (2d. McGeMatrix3d. md) | 3D matrix object |
Returns
Copy the 3D matrix object
//Matrix1 is a three-dimensional matrix object
const matrix = new McGeMatrix3d();
matrix.copy(matrix1)
det
▸ det(): number
Find the determinant of a matrix.
Returns
number
The determinant of a matrix.
Example
//Matrix represents a three-dimensional matrix object
const detNum = matrix.det();
console.log(detNum)
getData
▸ getData(row
, col
): number
Retrieve the element values at the specified position in the matrix.
Parameters
Name | Type | Description |
---|---|---|
Row | Number | Row index |
Col | number | column index |
Returns
number
The element value at the specified location.
Example
//Matrix represents a three-dimensional matrix object
const data = matrix.getData(2,3)
console.log(data)
invert
▸ invert(): McGeMatrix3d
Find the inverse matrix of the matrix.
Returns
Example
//Matrix represents a three-dimensional matrix object
const mat_invert = matrix.clone().invert();
isEqualTo
▸ isEqualTo(mat
): boolean
Determine whether the matrix is equal to the specified matrix.
Parameters
Name | Type | Description |
---|---|---|
mat | [McGeMatrix3d ] (2d. McGeMatrix3d. md) | The specified matrix |
Returns
boolean
If they are equal, return true; otherwise, return false.
Example
//Matrix1 and Matrix2 represent two three-dimensional matrix objects
const res = matrix1.isEqualTo(matrix2);
console.log(res)
isSingular
▸ isSingular(): boolean
Determine whether the matrix is a singular matrix.
Returns
boolean
If it is a singular matrix, return true; otherwise, return false.
Example
//Matrix represents a three-dimensional matrix object
const res = matrix.isSingular();
console.log(res)
postMultBy
▸ postMultBy(rightSide
): McGeMatrix3d
Right multiply the specified matrix.
Parameters
Name | Type |
---|---|
rightSide | McGeMatrix3d |
Returns
Return the matrix after right multiplication
Example
//Matrix1 represents a three-dimensional matrix object
const matrix = new McGeMatrix3d()
matrix.postMultBy(matrix1);
preMultBy
▸ preMultBy(leftSide
): McGeMatrix3d
Left multiply the specified matrix.
Parameters
Name | Type | Description |
---|---|---|
LeftSide | McGeMatrix3d (2d. McGeMatrix3d. md) | Left side matrix |
Returns
Return the matrix after left multiplication
Example
//Matrix1 represents a three-dimensional matrix object
const matrix = new McGeMatrix3d()
matrix.preMultBy(matrix1);
scale
▸ scale(): number
Obtain the scaling factor of the matrix.
Returns
number
The scaling factor of the matrix.
Example
//Matrix represents a three-dimensional matrix object
const scaleNum = matrix.scale()
console.log(scaleNum)
setCoordSystem
▸ setCoordSystem(origin
, xAxis
, yAxis
, zAxis
): McGeMatrix3d
Set the matrix to the specified coordinate system.
Parameters
Name | Type | Description |
---|---|---|
Origin | [McGePoint3d] (2d. McGePoint3d. md) | Coordinate system origin |
XAxis | [McGeVector3d] (2d. McGeVector3d. md) | X-axis vector |
YAxis | [McGeVector3d] (2d. McGeVector3d. md) | Y-axis vector |
ZAxis | [McGeVector3d] (2d. McGeVector3d. md) | Z-axis vector |
Returns
Example
import { McGeMatrix3d , McGePoint3d, McGeVector3d} from "mxcad"
const m1 = new McGeMatrix3d()
m1.setCoordSystem(new McGePoint3d(), new McGeVector3d(), new McGeVector3d(), new McGeVector3d())
setData
▸ setData(row
, col
, val
): void
Set the element values at the specified position in the matrix.
Parameters
Name | Type | Description |
---|---|---|
Row | Number | Row index |
Col | number | column index |
Val | number | The value of the element at the specified location |
Returns
void
Example
setMirror
▸ setMirror(pt1
, pt2
): McGeMatrix3d
Set the matrix as a mirror matrix
Parameters
Name | Type |
---|---|
pt1 | McGePoint3d |
pt2 | McGePoint3d |
Returns
Example
import { McGeMatrix3d, McDbEntity } from "mxcad";
const matrix = new McGeMatrix3d();
const event = new McDbEntity();
matrix.setMirror(new McGeVector3d(0, 0, 0), new McGeVector3d(20, 0, 0));// translation
event.transformBy(matrix);
setToIdentity
▸ setToIdentity(): McGeMatrix3d
Set the matrix to an identity matrix.
Returns
Example
//Matrix represents a three-dimensional matrix object
matrix.setToIdentity()
setToProduct
▸ setToProduct(mat1
, mat2
): McGeMatrix3d
Set the matrix as the product of two matrices.
Parameters
Name | Type | Description |
---|---|---|
Mat1 | [McGeMatrix3d] (2d. McGeMatrix3d. md) | First matrix |
Mat2 | [McGeMatrix3d] (2d. McGeMatrix3d. md) | Second matrix |
Returns
Example
//Matrix1 and Matrix2 represent two three-dimensional matrix objects
const matrix = new McGeMatrix3d()
matrix.setToProduct(matrix1, matrix2);
setToRotation
▸ setToRotation(angle
, axis
, center
): McGeMatrix3d
Set the matrix to rotate around a specified axis by a specified angle.
Parameters
Name | Type | Description |
---|---|---|
Angle | number | rotation angle |
Axis | [McGeVector3d] (2d. McGeVector3d. md) | Rotation axis vector |
Center | [McGePoint3d] (2d. McGePoint3d. md) | Rotate the center point |
Returns
Example
import { McGeMatrix3d, McDbEntity } from "mxcad";
let matrix = new McGeMatrix3d();
const event = new McDbEntity();
matrix.setToRotation(Math.PI, McGeVector3d.kZAxis / 180.0, new McGeVector3d(20,10,0));// translation
event.transformBy(matrix);
setToScaling
▸ setToScaling(scaleAll
, center
): McGeMatrix3d
Set the matrix as a scaling matrix.
Parameters
Name | Type | Description |
---|---|---|
ScaleAll | number | scaling factor |
Center | [McGePoint3d] (2d. McGePoint3d. md) | Scale the center point |
Returns
Example
import { McGeMatrix3d, McDbEntity } from "mxcad";
let matrix = new McGeMatrix3d();
const event = new McDbEntity();
matrix.setToScaling(0.5, new McGeVector3d(0, 0, 0));// translation
event.transformBy(matrix);
setToTranslation
▸ setToTranslation(vec
): McGeMatrix3d
Set the matrix as a translation matrix.
Parameters
Name | Type | Description |
---|---|---|
Vec | [McGeVector3d] (2d. McGeVector3d. md) | Translation vector |
Returns
Example
import { McGeMatrix3d, McDbEntity } from "mxcad";
let matrix = new McGeMatrix3d();
const event = new McDbEntity();
matrix.setToTranslation(new McGeVector3d(20,10,0));// translation
event.transformBy(matrix);
transposeIt
▸ transposeIt(): McGeMatrix3d
Transpose the matrix.
Returns
Example
//Matrix represents a three-dimensional matrix object
const mst_trs = matrix.clone().transposeIt();