Skip to content
On this page

[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

NameTypeDescription
dX?Number \object
dY?NumberY coordinate
dZ?NumberZ coordinate

Example

ts
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

ts
const origin = McGePoint3d.kOrigin;

Accessors

x

get x(): number

Get or set the X coordinate.

Returns

number

Example

ts
import { McGePoint3d } from "mxcad'

const point = new McGePoint3d();
point.x = 10;
Console. log (point. x)//Output 10

set x(val): void

Parameters

NameType
valnumber

Returns

void


y

get y(): number

Get or set the Y coordinate.

Returns

number

Example

ts
import { McGePoint3d } from "mxcad'

const point = new McGePoint3d();
point.y = 10;
Console. log (point. y)//Output 10

set y(val): void

Parameters

NameType
valnumber

Returns

void


z

get z(): number

Get or set the Z coordinate.

Returns

number

Example

ts
import { McGePoint3d } from "mxcad'

const point = new McGePoint3d();
point.z = 10;
Console. log (point. z)//Output 10

set z(val): void

Parameters

NameType
valnumber

Returns

void

Methods

addvec

addvec(vec): McGePoint3d

Calculate the new position of the point after adding the vector

Parameters

NameTypeDescription
Vec[McGeVector3d] (2d. McGeVector3d. md)Vector

Returns

McGePoint3d

Calculated point object

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

Calculate the new position of the point after adding the vector

Parameters

NameTypeDescription
Vec[McGeVector3d] (2d. McGeVector3d. md)Vector

Returns

McGePoint3d

Calculated point object


c

c(): McGePoint3d

Kerong, a point object

Returns

McGePoint3d

3D point object


clone

clone(): McGePoint3d

Kerong, a point object

Returns

McGePoint3d

3D point object

Example

ts
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

NameTypeDescription
Val[McGePoint3d] (2d. McGePoint3d. md)Point Object

Returns

McGePoint3d

Copy the point object

Example

ts
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

NameTypeDescription
PntMcGePoint3d (2d. McGePoint3d. md)3D point object

Returns

number

Distance between two points

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

Determine whether two points are equal

Parameters

NameTypeDescription
PntMcGePoint3d (2d. McGePoint3d. md)3D point object

Returns

boolean

Boolean value

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)//Output false

setFromVector3

setFromVector3(val): McGePoint3d

Set the vector of Three.js to points

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

Return a new vector obtained by subtracting two points

Parameters

NameTypeDescription
PtMcGePoint3d (2d. McGePoint3d. md)3D point object

Returns

McGeVector3d

3D point vector

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

Calculate the new position of the point after subtracting the vector

Parameters

NameTypeDescription
Vec[McGeVector3d] (2d. McGeVector3d. md)Vector

Returns

McGePoint3d

Calculated point object

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

Calculate the new position of the point after subtracting the vector

Parameters

NameTypeDescription
Vec[McGeVector3d] (2d. McGeVector3d. md)Vector

Returns

McGePoint3d

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

ts
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

NameTypeDescription
LeftSideMcGeMatrix3d (2d. McGeMatrix3d. md)Transformation Matrix

Returns

McGePoint3d

The transformed point object

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));// translation
  point.transformBy(matrix);