[mxcad_2d API documentation] (../README. md)/[2d] (../modules/2d. md)/McGePoint3d
Class: McGePoint3d
2d.McGePoint3d
An object that represents a three-dimensional point.
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new McGePoint3d(dX?, dY?, dZ?)
Constructor.
Example
import { McGePoint3d } from 'mxcad'
const point = new McGePoint3d(20,10,0);Parameters
| Name | Type | Description |
|---|---|---|
dX? | Number \ | object |
dY? | Number | Y coordinate |
dZ? | Number | Z coordinate |
Properties
imp
• imp: any
Internal implementation object
kOrigin
▪ Static kOrigin: McGePoint3d
Origin of coordinate system
Example
const origin = McGePoint3d.kOrigin;Accessors
x
• get x(): number
Get or set the X coordinate.
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.x = 10;
Console. log (point. x)//Output 10Returns
number
• set x(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
y
• get y(): number
Get or set the Y coordinate.
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.y = 10;
Console. log (point. y)//Output 10Returns
number
• set y(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
z
• get z(): number
Get or set the Z coordinate.
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.z = 10;
Console. log (point. z)//Output 10Returns
number
• set z(val): void
Parameters
| Name | Type |
|---|---|
val | number |
Returns
void
Methods
addvec
▸ addvec(vec): McGePoint3d
Calculate the new position of the point after adding the vector
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] (2d. McGeVector3d. md) | Vector |
Returns
Calculated point object
av
▸ av(vec): McGePoint3d
Calculate the new position of the point after adding the vector
Parameters
| Name | Type | Description |
|---|---|---|
| Vec | [McGeVector3d] (2d. McGeVector3d. md) | Vector |
Returns
Calculated point object
c
▸ c(): McGePoint3d
Kerong, a point object
Returns
3D point object
clone
▸ clone(): McGePoint3d
Kerong, a point object
Example
import { McGePoint3d } from "mxcad"
const pt1 = new McGePoint3d(10,10,0);
const pt2 = pt1.clone();Returns
3D point object
copy
▸ copy(val): McGePoint3d
Copy the value of a point object
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] (2d. McGePoint3d. md) | Point Object |
Returns
Copy the point object
distanceTo
▸ distanceTo(pnt): number
Calculate the distance between two points
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 (2d. McGePoint3d. md) | 3D point object |
Returns
number
Distance between two points
isEqualTo
▸ isEqualTo(pnt): boolean
Determine whether two points are equal
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)//Output falseParameters
| Name | Type | Description |
|---|---|---|
| Pnt | McGePoint3d (2d. McGePoint3d. md) | 3D point object |
Returns
boolean
Boolean value
setFromVector3
▸ setFromVector3(val): McGePoint3d
Set the vector of Three.js to points
Example
import { McGePoint3d } from "mxcad";
const pt_vec = new THREE.Vector3(20,50,0);
const pt = pt_vec.setFromVector3();Parameters
| Name | Type |
|---|---|
val | Vector3 |
Returns
sub
▸ sub(pt): McGeVector3d
Return a new vector obtained by subtracting two points
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 (2d. McGePoint3d. md) | 3D point object |
Returns
3D point vector
subvec
▸ subvec(vec): McGePoint3d
Calculate the new position of the point after subtracting the vector
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] (2d. McGeVector3d. md) | Vector |
Returns
Calculated point object
sv
▸ sv(vec): McGePoint3d
Calculate the new position of the point after subtracting the vector
Parameters
| Name | Type | Description |
|---|---|---|
| Vec | [McGeVector3d] (2d. McGeVector3d. md) | Vector |
Returns
Calculated point object
toVector3
▸ toVector3(): Vector3
Convert the coordinate information of the current object to THREE Instances of Vector3 class
Example
import { McGePoint3d } from "mxcad";
const pt = new McGePoint3d(20,10,0);
const pt_vec = pt.toVector3();Returns
Vector3
THREE. Vector3 instance object
transformBy
▸ transformBy(leftSide): McGePoint3d
Transform the point using a matrix
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));// translation
point.transformBy(matrix);Parameters
| Name | Type | Description |
|---|---|---|
| LeftSide | McGeMatrix3d (2d. McGeMatrix3d. md) | Transformation Matrix |
Returns
The transformed point object
