Skip to content

[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

ts
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 ​

Constructors ​

constructor ​

• new McGeMatrix3d(imp?)

Constructor.

Parameters ​

NameTypeDescription
imp?` ObjectInternal 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 ​

NameType
matMatrix4

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

ts

clone ​

▸ clone(): McGeMatrix3d

Create a three-dimensional matrix object for Kelon

Returns ​

McGeMatrix3d

3D matrix object


copy ​

▸ copy(val): McGeMatrix3d

Copy the value of the object

Parameters ​

NameTypeDescription
Val[McGeMatrix3d] (2d. McGeMatrix3d. md)3D matrix object

Returns ​

McGeMatrix3d

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 ​

NameTypeDescription
RowNumberRow index
Colnumbercolumn 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 ​

McGeMatrix3d


isEqualTo ​

▸ isEqualTo(mat): boolean

Determine whether the matrix is equal to the specified matrix.

Parameters ​

NameTypeDescription
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 ​

NameType
rightSideMcGeMatrix3d

Returns ​

McGeMatrix3d

Return the matrix after right multiplication


preMultBy ​

▸ preMultBy(leftSide): McGeMatrix3d

Left multiply the specified matrix.

Parameters ​

NameTypeDescription
LeftSideMcGeMatrix3d (2d. McGeMatrix3d. md)Left side matrix

Returns ​

McGeMatrix3d

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

ts
//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 ​

NameTypeDescription
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 ​

McGeMatrix3d


setData ​

▸ setData(row, col, val): void

Set the element values at the specified position in the matrix.

Parameters ​

NameTypeDescription
RowNumberRow index
Colnumbercolumn index
ValnumberThe value of the element at the specified location

Returns ​

void


setDatas ​

▸ setDatas(str): boolean

Parameters ​

NameType
strstring

Returns ​

boolean


setMirror ​

▸ setMirror(pt1, pt2): McGeMatrix3d

Set the matrix as a mirror matrix

Parameters ​

NameTypeDescription
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 ​

McGeMatrix3d

Example

ts
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 ​

McGeMatrix3d


setToProduct ​

▸ setToProduct(mat1, mat2): McGeMatrix3d

Set the matrix as the product of two matrices.

Parameters ​

NameTypeDescription
Mat1[McGeMatrix3d] (2d. McGeMatrix3d. md)First matrix
Mat2[McGeMatrix3d] (2d. McGeMatrix3d. md)Second matrix

Returns ​

McGeMatrix3d


setToRotation ​

▸ setToRotation(angle, axis, center): McGeMatrix3d

Set the matrix to rotate around a specified axis by a specified angle.

Parameters ​

NameTypeDescription
Anglenumberrotation angle
Axis[McGeVector3d] (2d. McGeVector3d. md)Rotation axis vector
Center[McGePoint3d] (2d. McGePoint3d. md)Rotate the center point

Returns ​

McGeMatrix3d

Example

ts
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 ​

NameTypeDescription
ScaleAllnumberscaling factor
Center[McGePoint3d] (2d. McGePoint3d. md)Scale the center point

Returns ​

McGeMatrix3d

Example

ts
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 ​

NameTypeDescription
Vec[McGeVector3d] (2d. McGeVector3d. md)Translation vector

Returns ​

McGeMatrix3d

Example

ts
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.

Returns ​

McGeMatrix3d