Skip to content
On this page

[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

Constructors

constructor

new McGeMatrix3d(imp?)

Constructor.

Parameters

NameTypeDescription
imp?` ObjectInternal implementation object

Example

ts
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

ts
___

### 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

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

Returns

McGeMatrix3d

Copy the 3D matrix object

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

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

NameTypeDescription
RowNumberRow index
Colnumbercolumn index

Returns

number

The element value at the specified location.

Example

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

McGeMatrix3d

Example

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

NameTypeDescription
mat[McGeMatrix3d] (2d. McGeMatrix3d. md)The specified matrix

Returns

boolean

If they are equal, return true; otherwise, return false.

Example

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

ts
//Matrix represents a three-dimensional matrix object
const res = matrix.isSingular();
console.log(res)

postMultBy

postMultBy(rightSide): McGeMatrix3d

Right multiply the specified matrix.

Parameters

NameType
rightSideMcGeMatrix3d

Returns

McGeMatrix3d

Return the matrix after right multiplication

Example

ts
//Matrix1 represents a three-dimensional matrix object
const matrix = new McGeMatrix3d()
matrix.postMultBy(matrix1);

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

Example

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

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

Example

ts
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

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

Returns

void

Example

ts

setMirror

setMirror(pt1, pt2): McGeMatrix3d

Set the matrix as a mirror matrix

Parameters

NameType
pt1McGePoint3d
pt2McGePoint3d

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));// translation
 event.transformBy(matrix);

setToIdentity

setToIdentity(): McGeMatrix3d

Set the matrix to an identity matrix.

Returns

McGeMatrix3d

Example

ts
//Matrix represents a three-dimensional matrix object
matrix.setToIdentity()

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

Example

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

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));// translation
 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));// translation
 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));// translation
 event.transformBy(matrix);

transposeIt

transposeIt(): McGeMatrix3d

Transpose the matrix.

Returns

McGeMatrix3d

Example

ts
//Matrix represents a three-dimensional matrix object
const mst_trs = matrix.clone().transposeIt();