Hide menu
Loading...
Searching...
No Matches
Point

Defines point in 3D space.

Constructors

new Point()

new Point(x?, y?, z?): Point

Parameters

x?

number

X coordinate of 3D point.

y?

number

Y coordinate of 3D point.

z?

number

Z coordinate of 3D point.

Returns

Point

Accessors

x

Get Signature

get x(): number

Returns x coordinate of 3D point.

Returns

number

Set Signature

set x(x): void

Sets x coordinate of 3D point.

Parameters

x

number

X coordinate.

Returns

void


y

Get Signature

get y(): number

Returns y coordinate of 3D point.

Returns

number

Set Signature

set y(y): void

Sets y coordinate of 3D point.

Parameters

y

number

Y coordinate.

Returns

void


z

Get Signature

get z(): number

Returns z coordinate of 3D point.

Returns

number

Set Signature

set z(z): void

Sets z coordinate of 3D point.

Parameters

z

number

Z coordinate.

Returns

void

Methods

add()

add(other): this

Adds other vector coordinates to this point coordinates.

Parameters

other

Vector

Other 3D vector.

Returns

this


added()

Call Signature

added(other): Point

Returns new Point object with coordinates received by performing an add() operation to this object.

Parameters

other

Vector

Other vector.

Returns

Point

Call Signature

added(other): Point

Returns new Point object with coordinates received by performing an add operation to this object.

Parameters

other

Point

Other point.

Returns

Point


clone()

clone(): Point

Creates new Point object with coordinates same as this.

Returns

Point


copy()

copy(other): this

Copies the coordinates of the other point to this.

Parameters

other

Point

Copied object.

Returns

this


distance()

distance(other): number

Returns distance between other point and this point.

Parameters

other

Point

Other point.

Returns

number


divide()

divide(scalar): this

Divide this point coordinates by scalar value.

Parameters

scalar

number

Scalar value.

Returns

this


divided()

divided(scalar): Point

Returns new Point object with coordinates received by performing a divide() operation to this object.

Parameters

scalar

number

Scalar value.

Returns

Point


get()

get(index): number

Returns coordinate value of 2D point:

  • X coordinate if index equals 0
  • Y coordinate if index equals 1
  • Z coordinate if index equals 2

Throws exception if index is not in range [0, 2].

Parameters

index

number

Coordinate index.

Returns

number


isEqual()

isEqual(other, tolerance?): boolean

Returns true if other point coordinates are equal to this point coordinated within provided tolerance (1e-7 by default). Returns false otherwise.

Parameters

other

Point

Other 3D point.

tolerance?

number

Coordinates comparison tolerance;

Returns

boolean


mirror()

Call Signature

mirror(point): this

Mirrors this 3D point relative to other point.

Parameters

point

Point

Other point.

Returns

this

Call Signature

mirror(axis): this

Mirrors this 3D point relative to axis.

Parameters

axis

Axis1d

Axis.

Returns

this

Call Signature

mirror(axis): this

Mirrors this 3D point relative to axis.

Parameters

axis

Axis3d

Axis.

Returns

this


mirrored()

Call Signature

mirrored(point): Point

Returns new Point object with coordinates received by performing a mirror() operation to this object.

Parameters

point

Point

Point.

Returns

Point

Call Signature

mirrored(axis): Point

Returns new Point object with coordinates received by performing a mirror() operation to this object.

Parameters

axis

Axis1d

Axis.

Returns

Point

Call Signature

mirrored(axis): Point

Returns new Point object with coordinates received by performing a mirror() operation to this object.

Parameters

axis

Axis3d

Axis.

Returns

Point


multiplied()

Call Signature

multiplied(matrix): Point

Returns new Point object with coordinates received by performing a multiply() operation to this object.

Parameters

matrix

Matrix3d

3D matrix.

Returns

Point

Call Signature

multiplied(scalar): Point

Returns new Point object with coordinates received by performing a multiply() operation to this object.

Parameters

scalar

number

Scalar value.

Returns

Point


multiply()

Call Signature

multiply(matrix): this

Multiplies this vector coordinates with 3D matrix.

Parameters

matrix

Matrix3d

3D matrix.

Returns

this

Call Signature

multiply(scalar): this

Multiplies this vector coordinates with scalar value.

Parameters

scalar

number

Scalar value.

Returns

this


rotate()

rotate(axis, angle): this

Rotates this 3D point around axis on angle.

Parameters

axis

Axis1d

Rotation axis.

angle

number

Rotation angle.

Returns

this


rotated()

rotated(axis, angle): Point

Returns new Point object with coordinates received by performing a rotate() operation to this object.

Parameters

axis

Axis1d

Rotation axis.

angle

number

Rotation angle.

Returns

Point


scale()

scale(other, scale): this

Adds other point coordinates to this point coordinates, multiplied by scale.

Parameters

other

Point

Other point.

scale

number

Scale value.

Returns

this


scaled()

scaled(other, scale): Point

Returns new Point object with coordinates received by performing a scale() operation to this object.

Parameters

other

Point

Other point.

scale

number

Scale value.

Returns

Point


set()

set(index, value): this

Sets coordinate value of 2D point:

  • X coordinate if index equals 0
  • Y coordinate if index equals 1
  • Z coordinate if index equals 2

Throws exception if index is not in range [0, 2].

Parameters

index

number

Coordinate index.

value

number

Coordinate value.

Returns

this


setCoord()

setCoord(x?, y?, z?): this

Sets x, y and z coordinates of this object.

Parameters

x?

number

X coordinate of 3D point.

y?

number

Y coordinate of 3D point.

z?

number

Returns

this


setX()

setX(x): this

Sets x coordinate of 3D point.

Parameters

x

number

X coordinate.

Returns

this


setY()

setY(y): this

Sets y coordinate of 3D point.

Parameters

y

number

Y coordinate.

Returns

this


setZ()

setZ(z): this

Sets z coordinate of 3D point.

Parameters

z

number

Z coordinate.

Returns

this


subtract()

subtract(other): this

Subtracts other vector coordinates from this point coordinates.

Parameters

other

Vector

Other vector.

Returns

this


subtracted()

Call Signature

subtracted(other): Point

Returns new Point object with coordinates received by performing a subtract() operation to this object.

Parameters

other

Vector

Other vector.

Returns

Point

Call Signature

subtracted(other): Vector

Returns new Point object with coordinates received by performing a subtract operation to this object.

Parameters

other

Point

Other point.

Returns

Vector


toJSON()

toJSON(): BaseXYZ

Returns JSON representation of this point.

Returns

BaseXYZ


toString()

toString(precision): string

Returns string representation of this point with provided precision (3 by default).

Parameters

precision

number = 3

Precision.

Returns

string


transform()

transform(transformation): this

Transforms coordinates of this point according to transformation.

Parameters

transformation

Transformation

Transformation.

Returns

this


transformed()

transformed(transformation): Point

Returns new Point object with coordinates received by performing a transform() operation to this object.

Parameters

transformation

Transformation

Transformation.

Returns

Point


translate()

translate(vector): this

Translates this point coordinates.

Parameters

vector

Vector

Translation vector.

Returns

this


translated()

translated(vector): Point

Returns new Point object with coordinates received by performing a translate() operation to this object.

Parameters

vector

Vector

Translation vector.

Returns

Point


fromXYZ()

static fromXYZ(xyz): Point

Creates new Point object from object implementing BaseXYZ interface.

Parameters

xyz

BaseXYZ

Object implementing BaseXYZ interface.

Returns

Point


origin()

static origin(): Point

Returns Point with (0, 0, 0) coordinates.

Returns

Point