mxcad_2d API 文档 / 2d / McGePoint3d
Class: McGePoint3d
2d.McGePoint3d
表示三维点的对象。
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new McGePoint3d(dX?, dY?, dZ?)
构造函数。
Example
import { McGePoint3d } from 'mxcad'
const point = new McGePoint3d(20,10,0);Parameters
| Name | Type | Description |
|---|---|---|
dX? | number | object | X 坐标。 |
dY? | number | Y 坐标。 |
dZ? | number | Z 坐标。 |
Properties
imp
• imp: any
内部实现对象
kOrigin
▪ Static kOrigin: McGePoint3d
坐标系的原点
Example
const origin = McGePoint3d.kOrigin;Accessors
x
• get x(): number
获取或设置 X 坐标。
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.x = 10;
console.log(point.x)//输出10Returns
number
• set x(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
y
• get y(): number
获取或设置 Y 坐标。
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.y = 10;
console.log(point.y)//输出10Returns
number
• set y(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
z
• get z(): number
获取或设置 Z 坐标。
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.z = 10;
console.log(point.z)//输出10Returns
number
• set z(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
Methods
addvec
▸ addvec(vec): McGePoint3d
计算点加上向量后的新位置
Example
import { McGePoint3d, McGeVector3d } from "mxcad";
const pt1 = new McGePoint3d(20,10,0);
const pt = pt1.clone().addvec(new McGeVector3d(10,10,0))Parameters
| Name | Type | Description |
|---|---|---|
vec | McGeVector3d | 向量 |
Returns
计算后的点对象
av
▸ av(vec): McGePoint3d
计算点加上向量后的新位置
Parameters
| Name | Type | Description |
|---|---|---|
vec | McGeVector3d | 向量 |
Returns
计算后的点对象
c
▸ c(): McGePoint3d
刻隆一个点对象
Returns
三维点对象
clone
▸ clone(): McGePoint3d
刻隆一个点对象
Example
import { McGePoint3d } from "mxcad"
const pt1 = new McGePoint3d(10,10,0);
const pt2 = pt1.clone();Returns
三维点对象
copy
▸ copy(val): McGePoint3d
复制点对象的值
Example
import { McGePoint3d } from "mxcad"
const point1 = new McGePoint3d(20,10,0);
const point2 = new McGePoint3d();
point2.copy(point1);Parameters
| Name | Type | Description |
|---|---|---|
val | McGePoint3d | 点对象 |
Returns
复制后的点对象
distanceTo
▸ distanceTo(pnt): number
计算两点距离
Example
import { McGePoint3d } from "mxcad";
const pt1 = new McGePoint3d(20,10,0);
const pt2 = new McGePoint3d(50,20,0);
const dist = pt1.distanceTo(pt2);Parameters
| Name | Type | Description |
|---|---|---|
pnt | McGePoint3d | 三维点对象 |
Returns
number
两点距离
isEqualTo
▸ isEqualTo(pnt): boolean
判断两个点是否相等
Example
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)//输出falseParameters
| Name | Type | Description |
|---|---|---|
pnt | McGePoint3d | 三维点对象 |
Returns
boolean
布尔值
setFromVector3
▸ setFromVector3(val): McGePoint3d
将three.js 的向量设置成点
Example
import { McGePoint3d } from "mxcad";
import THREE from "three";
const pt_vec = new THREE.Vector3(20,50,0);
const pt = pt_vec.setFromVector3();Parameters
| Name | Type |
|---|---|
val | Vector3 |
Returns
sub
▸ sub(pt): McGeVector3d
返回两点相减后得到的一个新的向量
Example
import { McGePoint3d } from "mxcad";
const pt1 = new McGePoint3d(20,10,0);
const pt2 = new McGePoint3d(50,20,0);
const vec = pt1.sub(pt2);Parameters
| Name | Type | Description |
|---|---|---|
pt | McGePoint3d | 三维点对象 |
Returns
三维点向量
subvec
▸ subvec(vec): McGePoint3d
计算点减去向量后的新位置
Example
import { McGePoint3d, McGeVector3d } from "mxcad";
const pt1 = new McGePoint3d(20,10,0);
const pt = pt1.clone().subvec(new McGeVector3d(10,10,0));Parameters
| Name | Type | Description |
|---|---|---|
vec | McGeVector3d | 向量 |
Returns
计算后的点对象
sv
▸ sv(vec): McGePoint3d
计算点减去向量后的新位置
Parameters
| Name | Type | Description |
|---|---|---|
vec | McGeVector3d | 向量 |
Returns
计算后的点对象
toVector3
▸ toVector3(): Vector3
将当前对象的坐标信息转换为 THREE.Vector3 类的实例
Example
import { McGePoint3d } from "mxcad";
const pt = new McGePoint3d(20,10,0);
const pt_vec = pt.toVector3();Returns
Vector3
THREE.Vector3实例对象
transformBy
▸ transformBy(leftSide): McGePoint3d
使用矩阵变换该点
Example
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);Parameters
| Name | Type | Description |
|---|---|---|
leftSide | McGeMatrix3d | 变换矩阵 |
Returns
变换后的点对象