[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGeMatrix3d
Class: McGeMatrix3d
2d.McGeMatrix3d
McGeMatrix3d represents the transformation matrix object in three-dimensional space.
Description
This class is used to construct and apply geometric transformation matrices such as translation, rotation, scaling, and mirroring, Can be used for spatial transformations of points, vectors, and solid objects. It is one of the core types for implementing CAD graphic transformation and coordinate system conversion.
Example
import { McGeMatrix3d, McGePoint3d, McGeVector3d } from "mxcad";
const matrix = new McGeMatrix3d();
matrix.setToTranslation(new McGeVector3d(20, 10, 0)); //Translation matrix
const pt = new McGePoint3d(1, 2, 0);
pt.transformBy(matrix); //Apply translation matrix
console.log(pt.x, pt.y, pt.z);Table of contents
Constructors
Properties
Accessors
Methods
- angleXYPlane
- clone
- copy
- det
- getData
- getDatas
- invert
- isEqualTo
- isSingular
- postMultBy
- preMultBy
- scale
- setCoordSystem
- setData
- setDatas
- setMirror
- setToIdentity
- setToProduct
- setToRotation
- setToScaling
- setToTranslation
- toMatrix4
- transposeIt
Constructors
constructor
• new McGeMatrix3d(imp?)
Constructor.
Parameters
| Name | Type | Description |
|---|---|---|
imp? | ` Object | Internal implementation object |
Properties
imp
• imp: any
Internal implementation object
kIdentity
▪ Static kIdentity: McGeMatrix3d
The identity matrix of multiplication
Accessors
matrix4
• get matrix4(): Matrix4
Matrix definition data
Returns
Matrix4
• set matrix4(mat): void
Parameters
| Name | Type |
|---|---|
mat | Matrix4 |
Returns
void
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
Create a three-dimensional matrix object for Kelon
Returns
3D matrix object
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
det
▸ det(): number
Find the determinant of a matrix.
Returns
number
The determinant of a matrix.
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.
getDatas
▸ getDatas(): string
Return all defined data of the matrix.
Returns
string
invert
▸ invert(): McGeMatrix3d
Find the inverse matrix of the matrix.
Returns
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.
isSingular
▸ isSingular(): boolean
Determine whether the matrix is a singular matrix.
Returns
boolean
If it is a singular matrix, return true; otherwise, return false.
postMultBy
▸ postMultBy(rightSide): McGeMatrix3d
Right multiply the specified matrix.
Parameters
| Name | Type |
|---|---|
rightSide | McGeMatrix3d |
Returns
Return the matrix after right multiplication
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
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
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
setDatas
▸ setDatas(str): boolean
Parameters
| Name | Type |
|---|---|
str | string |
Returns
boolean
setMirror
▸ setMirror(pt1, pt2): McGeMatrix3d
Set the matrix as a mirror matrix
Parameters
| Name | Type | Description |
|---|---|---|
| Pt1 | [McGePoint3d] (2d. McGePoint3d. md) | The first point on the mirror plane. |
| Pt2 | [McGePoint3d] (2d. McGePoint3d. md) | The second point on the mirror plane. |
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));
event.transformBy(matrix);setToIdentity
▸ setToIdentity(): McGeMatrix3d
Set the matrix to an identity matrix.
Returns
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
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));
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));
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));
event.transformBy(matrix);toMatrix4
▸ toMatrix4(): Matrix4
Return to THREE. Matrix4
Returns
Matrix4
transposeIt
▸ transposeIt(): McGeMatrix3d
Transpose the matrix.
