Skip to content
On this page

mxcad_2d API 文档 / 2d / McGePoint3d

Class: McGePoint3d

2d.McGePoint3d

表示三维点的对象。

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new McGePoint3d(dX?, dY?, dZ?)

构造函数。

Parameters

NameTypeDescription
dX?number | objectX 坐标。
dY?numberY 坐标。
dZ?numberZ 坐标。

Example

ts
import { McGePoint3d } from 'mxcad'

const point = new McGePoint3d(20,10,0);

Properties

imp

imp: any

内部实现对象


kOrigin

Static kOrigin: McGePoint3d

坐标系的原点

Example

ts
const origin = McGePoint3d.kOrigin;

Accessors

x

get x(): number

获取或设置 X 坐标。

Returns

number

Example

ts
import { McGePoint3d } from "mxcad'

const point = new McGePoint3d();
point.x = 10;
console.log(point.x)//输出10

set x(val): void

Parameters

NameType
valnumber

Returns

void


y

get y(): number

获取或设置 Y 坐标。

Returns

number

Example

ts
import { McGePoint3d } from "mxcad'

const point = new McGePoint3d();
point.y = 10;
console.log(point.y)//输出10

set y(val): void

Parameters

NameType
valnumber

Returns

void


z

get z(): number

获取或设置 Z 坐标。

Returns

number

Example

ts
import { McGePoint3d } from "mxcad'

const point = new McGePoint3d();
point.z = 10;
console.log(point.z)//输出10

set z(val): void

Parameters

NameType
valnumber

Returns

void

Methods

addvec

addvec(vec): McGePoint3d

计算点加上向量后的新位置

Parameters

NameTypeDescription
vecMcGeVector3d向量

Returns

McGePoint3d

计算后的点对象

Example

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

const pt1 = new McGePoint3d(20,10,0);
const pt = pt1.clone().addvec(new McGeVector3d(10,10,0))

av

av(vec): McGePoint3d

计算点加上向量后的新位置

Parameters

NameTypeDescription
vecMcGeVector3d向量

Returns

McGePoint3d

计算后的点对象


c

c(): McGePoint3d

刻隆一个点对象

Returns

McGePoint3d

三维点对象


clone

clone(): McGePoint3d

刻隆一个点对象

Returns

McGePoint3d

三维点对象

Example

ts
import { McGePoint3d } from "mxcad"

const pt1 = new McGePoint3d(10,10,0);
const pt2 = pt1.clone();

copy

copy(val): McGePoint3d

复制点对象的值

Parameters

NameTypeDescription
valMcGePoint3d点对象

Returns

McGePoint3d

复制后的点对象

Example

ts
import { McGePoint3d } from "mxcad"

const point1 = new McGePoint3d(20,10,0);
const point2 = new McGePoint3d();
point2.copy(point1);

distanceTo

distanceTo(pnt): number

计算两点距离

Parameters

NameTypeDescription
pntMcGePoint3d三维点对象

Returns

number

两点距离

Example

ts
import { McGePoint3d } from "mxcad";

const pt1 = new McGePoint3d(20,10,0);
const pt2 = new McGePoint3d(50,20,0);
const dist = pt1.distanceTo(pt2);

isEqualTo

isEqualTo(pnt): boolean

判断两个点是否相等

Parameters

NameTypeDescription
pntMcGePoint3d三维点对象

Returns

boolean

布尔值

Example

ts
import { McGePoint3d } from "mxcad"

const pt1 = new McGePoint3d(10,20,0);
const pt2 = new McGePoint3d(10,10,0);
const res = pt1.isEqualTo(pt2);
console.log(res)//输出false

setFromVector3

setFromVector3(val): McGePoint3d

将three.js 的向量设置成点

Parameters

NameType
valVector3

Returns

McGePoint3d

Example

ts
import { McGePoint3d } from "mxcad";
import THREE from "three";

const pt_vec = new THREE.Vector3(20,50,0);
const pt = pt_vec.setFromVector3();

sub

sub(pt): McGeVector3d

返回两点相减后得到的一个新的向量

Parameters

NameTypeDescription
ptMcGePoint3d三维点对象

Returns

McGeVector3d

三维点向量

Example

ts
import { McGePoint3d } from "mxcad";

const pt1 = new McGePoint3d(20,10,0);
const pt2 = new McGePoint3d(50,20,0);
const vec = pt1.sub(pt2);

subvec

subvec(vec): McGePoint3d

计算点减去向量后的新位置

Parameters

NameTypeDescription
vecMcGeVector3d向量

Returns

McGePoint3d

计算后的点对象

Example

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

const pt1 = new McGePoint3d(20,10,0);
const pt = pt1.clone().subvec(new McGeVector3d(10,10,0));

sv

sv(vec): McGePoint3d

计算点减去向量后的新位置

Parameters

NameTypeDescription
vecMcGeVector3d向量

Returns

McGePoint3d

计算后的点对象


toVector3

toVector3(): Vector3

将当前对象的坐标信息转换为 THREE.Vector3 类的实例

Returns

Vector3

THREE.Vector3实例对象

Example

ts
import { McGePoint3d } from "mxcad";
const pt = new McGePoint3d(20,10,0);
const pt_vec = pt.toVector3();

transformBy

transformBy(leftSide): McGePoint3d

使用矩阵变换该点

Parameters

NameTypeDescription
leftSideMcGeMatrix3d变换矩阵

Returns

McGePoint3d

变换后的点对象

Example

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

const point = new McGePoint3d(20,10,0);
  let matrix = new McGeMatrix3d();
  matrix.setToTranslation(new McGeVector3d(10,10,0));//平移
  point.transformBy(matrix);