[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.
Parameters
Name | Type | Description |
---|---|---|
dX? | Number \ | object |
dY? | Number | Y coordinate |
dZ? | Number | Z coordinate |
Example
import { McGePoint3d } from 'mxcad'
const point = new McGePoint3d(20,10,0);
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.
Returns
number
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.x = 10;
Console. log (point. x)//Output 10
• set
x(val
): void
Parameters
Name | Type |
---|---|
val | number |
Returns
void
y
• get
y(): number
Get or set the Y coordinate.
Returns
number
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.y = 10;
Console. log (point. y)//Output 10
• set
y(val
): void
Parameters
Name | Type |
---|---|
val | number |
Returns
void
z
• get
z(): number
Get or set the Z coordinate.
Returns
number
Example
import { McGePoint3d } from "mxcad'
const point = new McGePoint3d();
point.z = 10;
Console. log (point. z)//Output 10
• 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
Parameters
Name | Type | Description |
---|---|---|
Vec | [McGeVector3d] (2d. McGeVector3d. md) | Vector |
Returns
Calculated point object
Example
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
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
Returns
3D point object
Example
import { McGePoint3d } from "mxcad"
const pt1 = new McGePoint3d(10,10,0);
const pt2 = pt1.clone();
copy
▸ copy(val
): McGePoint3d
Copy the value of a point object
Parameters
Name | Type | Description |
---|---|---|
Val | [McGePoint3d] (2d. McGePoint3d. md) | Point Object |
Returns
Copy the point object
Example
import { McGePoint3d } from "mxcad"
const point1 = new McGePoint3d(20,10,0);
const point2 = new McGePoint3d();
point2.copy(point1);
distanceTo
▸ distanceTo(pnt
): number
Calculate the distance between two points
Parameters
Name | Type | Description |
---|---|---|
Pnt | McGePoint3d (2d. McGePoint3d. md) | 3D point object |
Returns
number
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);
isEqualTo
▸ isEqualTo(pnt
): boolean
Determine whether two points are equal
Parameters
Name | Type | Description |
---|---|---|
Pnt | McGePoint3d (2d. McGePoint3d. md) | 3D point object |
Returns
boolean
Boolean value
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 false
setFromVector3
▸ setFromVector3(val
): McGePoint3d
Set the vector of Three.js to points
Parameters
Name | Type |
---|---|
val | Vector3 |
Returns
Example
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
Return a new vector obtained by subtracting two points
Parameters
Name | Type | Description |
---|---|---|
Pt | McGePoint3d (2d. McGePoint3d. md) | 3D point object |
Returns
3D point vector
Example
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
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
Example
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
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
Returns
Vector3
THREE. Vector3 instance object
Example
import { McGePoint3d } from "mxcad";
const pt = new McGePoint3d(20,10,0);
const pt_vec = pt.toVector3();
transformBy
▸ transformBy(leftSide
): McGePoint3d
Transform the point using a matrix
Parameters
Name | Type | Description |
---|---|---|
LeftSide | McGeMatrix3d (2d. McGeMatrix3d. md) | Transformation Matrix |
Returns
The transformed point object
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);