Skip to content

mxcad_2d API 文档 / 2d / McGeMatrix3d

Class: McGeMatrix3d ​

2d.McGeMatrix3d

表示三维矩阵对象

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new McGeMatrix3d(imp?)

构造函数。

Example

ts
import { McGeMatrix3d } from "mxcad"

const matrix = new McGeMatrix3d()

Parameters ​

NameTypeDescription
imp?object内部实现对象

Properties ​

imp ​

• imp: any

内部实现对象


kIdentity ​

▪ Static kIdentity: McGeMatrix3d

乘法的单位矩阵

Methods ​

angleXYPlane ​

▸ angleXYPlane(): number

获取矩阵在XY平面的旋转角度因子。 @returns旋转角度因子。

Example

ts

Returns ​

number


clone ​

▸ clone(): McGeMatrix3d

刻隆一个三维矩阵对象

Example

ts
// matrix1 一个三维矩阵对象
const matrix = matrix1.clone()

Returns ​

McGeMatrix3d

三维矩阵对象


copy ​

▸ copy(val): McGeMatrix3d

复制对象的值

Parameters ​

NameTypeDescription
valMcGeMatrix3d三维矩阵对象

Returns ​

McGeMatrix3d

复制后的三维矩阵对象

ts
// matrix1 一个三维矩阵对象
const matrix = new McGeMatrix3d();
matrix.copy(matrix1)

det ​

▸ det(): number

求矩阵的行列式。

Example

ts
// matrix 表示一个三维矩阵对象
const detNum = matrix.det();
console.log(detNum)

Returns ​

number

矩阵的行列式。


getData ​

▸ getData(row, col): number

获取矩阵中指定位置的元素值。

Example

ts
// matrix 表示一个三维矩阵对象
const data = matrix.getData(2,3)
console.log(data)

Parameters ​

NameTypeDescription
rownumber行索引。
colnumber列索引。

Returns ​

number

指定位置的元素值。


getDatas ​

▸ getDatas(): string

返回矩阵的所有定义数据。

Example

ts

Returns ​

string


invert ​

▸ invert(): McGeMatrix3d

求矩阵的逆矩阵。

Example

ts
// matrix表示一个三维矩阵对象
const mat_invert = matrix.clone().invert();

Returns ​

McGeMatrix3d


isEqualTo ​

▸ isEqualTo(mat): boolean

判断矩阵是否与指定的矩阵相等。

Example

ts
// matrix1 matrix2 表示两个三维矩阵对象
const res = matrix1.isEqualTo(matrix2);
console.log(res)

Parameters ​

NameTypeDescription
matMcGeMatrix3d指定的矩阵。

Returns ​

boolean

如果相等返回 true,否则返回 false。


isSingular ​

▸ isSingular(): boolean

判断矩阵是否为奇异矩阵。

Example

ts
// matrix表示一个三维矩阵对象
const res = matrix.isSingular();
console.log(res)

Returns ​

boolean

如果是奇异矩阵返回 true,否则返回 false。


postMultBy ​

▸ postMultBy(rightSide): McGeMatrix3d

右乘指定的矩阵。

Example

ts
// matrix1 表示一个三维矩阵对象
const matrix = new McGeMatrix3d()
matrix.postMultBy(matrix1);

Parameters ​

NameType
rightSideMcGeMatrix3d

Returns ​

McGeMatrix3d

返回右乘后的矩阵


preMultBy ​

▸ preMultBy(leftSide): McGeMatrix3d

左乘指定的矩阵。

Example

ts
// matrix1 表示一个三维矩阵对象
const matrix = new McGeMatrix3d()
matrix.preMultBy(matrix1);

Parameters ​

NameTypeDescription
leftSideMcGeMatrix3d左侧矩阵。

Returns ​

McGeMatrix3d

返回左乘后的矩阵


scale ​

▸ scale(): number

获取矩阵的缩放因子。

Example

ts
// matrix 表示一个三维矩阵对象
const scaleNum = matrix.scale()
console.log(scaleNum)

Returns ​

number

矩阵的缩放因子。


setCoordSystem ​

▸ setCoordSystem(origin, xAxis, yAxis, zAxis): McGeMatrix3d

将矩阵设置为指定的坐标系。

Example

ts
import { McGeMatrix3d , McGePoint3d, McGeVector3d} from "mxcad"

const m1 = new McGeMatrix3d()
m1.setCoordSystem(new McGePoint3d(), new McGeVector3d(), new McGeVector3d(), new McGeVector3d())

Parameters ​

NameTypeDescription
originMcGePoint3d坐标系原点。
xAxisMcGeVector3dX 轴向量。
yAxisMcGeVector3dY 轴向量。
zAxisMcGeVector3dZ 轴向量。

Returns ​

McGeMatrix3d


setData ​

▸ setData(row, col, val): void

设置矩阵中指定位置的元素值。

Example

ts

Parameters ​

NameTypeDescription
rownumber行索引。
colnumber列索引。
valnumber指定位置的元素值。

Returns ​

void


setMirror ​

▸ setMirror(pt1, pt2): 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);

Parameters ​

NameType
pt1McGePoint3d
pt2McGePoint3d

Returns ​

McGeMatrix3d


setToIdentity ​

▸ setToIdentity(): McGeMatrix3d

将矩阵设置为单位矩阵。

Example

ts
// matrix 表示一个三维矩阵对象
matrix.setToIdentity()

Returns ​

McGeMatrix3d


setToProduct ​

▸ setToProduct(mat1, mat2): McGeMatrix3d

将矩阵设置为两个矩阵的乘积。

Example

ts
// matrix1 matrix2 表示两个三维矩阵对象
const matrix = new McGeMatrix3d()
matrix.setToProduct(matrix1, matrix2);

Parameters ​

NameTypeDescription
mat1McGeMatrix3d第一个矩阵。
mat2McGeMatrix3d第二个矩阵。

Returns ​

McGeMatrix3d


setToRotation ​

▸ setToRotation(angle, axis, center): 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);

Parameters ​

NameTypeDescription
anglenumber旋转角度。
axisMcGeVector3d旋转轴向量。
centerMcGePoint3d旋转中心点。

Returns ​

McGeMatrix3d


setToScaling ​

▸ setToScaling(scaleAll, center): 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);

Parameters ​

NameTypeDescription
scaleAllnumber缩放因子。
centerMcGePoint3d缩放中心点。

Returns ​

McGeMatrix3d


setToTranslation ​

▸ setToTranslation(vec): 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);

Parameters ​

NameTypeDescription
vecMcGeVector3d平移向量。

Returns ​

McGeMatrix3d


toMatrix4 ​

▸ toMatrix4(): Matrix4

返回THREE.Matrix4

Example

ts

Returns ​

Matrix4


transposeIt ​

▸ transposeIt(): McGeMatrix3d

将矩阵转置。

Example

ts
// matrix表示一个三维矩阵对象
const mst_trs = matrix.clone().transposeIt();

Returns ​

McGeMatrix3d