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

Defines a 3D point.

Constructors

Constructor

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

Creates a point from coordinates.

If coordinates are omitted, the point is created at (0, 0, 0).

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

X coordinate of the point.

Returns

number

Set Signature

‍set x(x): void

Sets the X coordinate of the point.

Parameters

x

number

X coordinate.

Returns

void


y

Get Signature

‍get y(): number

Y coordinate of the point.

Returns

number

Set Signature

‍set y(y): void

Sets the Y coordinate of the point.

Parameters

y

number

Y coordinate.

Returns

void


z

Get Signature

‍get z(): number

Z coordinate of the point.

Returns

number

Set Signature

‍set z(z): void

Sets the Z coordinate of the point.

Parameters

z

number

Z coordinate.

Returns

void

Methods

add()

‍add(other): this

Adds the coordinates of other to this point.

Parameters

other

Vector

Other 3D vector.

Returns

this


added()

Call Signature

‍added(other): Point

Returns a new point resulting from adding other to this point.

Parameters

other

Vector

Other vector.

Returns

Point

Call Signature

‍added(other): Point

Returns a new point whose coordinates are the sums of the coordinates of this point and other.

Parameters

other

Point

Other point.

Returns

Point


clone()

‍clone(): Point

Creates a new point with the same coordinates as this point.

Returns

Point


copy()

‍copy(other): this

Copies the coordinates of other to this point.

Parameters

other

Point

Point to copy.

Returns

this


distance()

‍distance(other): number

Returns the distance between this point and other.

Parameters

other

Point

Other point.

Returns

number


divide()

‍divide(scalar): this

Divides the coordinates of this point by scalar.

Parameters

scalar

number

Scalar value.

Returns

this


divided()

‍divided(scalar): Point

Returns a new point resulting from dividing this point by scalar.

Parameters

scalar

number

Scalar value.

Returns

Point


fromXYZ()

‍static fromXYZ(xyz): Point

Creates a point from an object implementing the BaseXYZ interface.

Parameters

xyz

BaseXYZ

Object implementing BaseXYZ interface.

Returns

Point


get()

‍get(index): number

Returns the coordinate value of the point:

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

Throws a RangeError if index is not in the range [0, 2].

Parameters

index

number

Coordinate index.

Returns

number


isEqual()

‍isEqual(other, tolerance?): boolean

Returns whether this point is equal to other within the provided coordinate tolerance.

Parameters

other

Point

Other 3D point.

tolerance?

number = Point.coincidenceTolerance

Coordinate comparison tolerance (1e-7 by default).

Returns

boolean


mirror()

Call Signature

‍mirror(point): this

Mirrors this point about point.

Parameters

point

Point

Other point.

Returns

this

Call Signature

‍mirror(axis): this

Mirrors this point about axis.

Parameters

axis

Axis1d

Axis.

Returns

this

Call Signature

‍mirror(axis): this

Mirrors this point about axis.

Parameters

axis

Axis3d

Axis.

Returns

this


mirrored()

Call Signature

‍mirrored(point): Point

Returns a new point resulting from mirroring this point about point.

Parameters

point

Point

Point.

Returns

Point

Call Signature

‍mirrored(axis): Point

Returns a new point resulting from mirroring this point about axis.

Parameters

axis

Axis1d

Axis.

Returns

Point

Call Signature

‍mirrored(axis): Point

Returns a new point resulting from mirroring this point about axis.

Parameters

axis

Axis3d

Axis.

Returns

Point


multiplied()

Call Signature

‍multiplied(matrix): Point

Returns a new point resulting from multiplying this point by matrix.

Parameters

matrix

Matrix3d

3D matrix.

Returns

Point

Call Signature

‍multiplied(scalar): Point

Returns a new point resulting from multiplying this point by scalar.

Parameters

scalar

number

Scalar value.

Returns

Point


multiply()

Call Signature

‍multiply(matrix): this

Multiplies the coordinates of this point by a 3D matrix.

Parameters

matrix

Matrix3d

3D matrix.

Returns

this

Call Signature

‍multiply(scalar): this

Multiplies the coordinates of this point by a scalar value.

Parameters

scalar

number

Scalar value.

Returns

this


origin()

‍static origin(): Point

Returns a point with coordinates (0, 0, 0).

Returns

Point


rotate()

‍rotate(axis, angle): this

Rotates this point around axis by angle.

Parameters

axis

Axis1d

Rotation axis.

angle

number

Rotation angle.

Returns

this


rotated()

‍rotated(axis, angle): Point

Returns a new point resulting from rotating this point.

Parameters

axis

Axis1d

Rotation axis.

angle

number

Rotation angle.

Returns

Point


scale()

‍scale(other, scale): this

Scales this point with respect to other.

The resulting coordinates are computed as other + scale * (this - other).

Parameters

other

Point

Other point.

scale

number

Scale value.

Returns

this


scaled()

‍scaled(other, scale): Point

Returns a new point resulting from scaling this point.

Parameters

other

Point

Other point.

scale

number

Scale value.

Returns

Point


set()

‍set(index, value): this

Sets the coordinate value of the point:

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

Throws a RangeError if index is not in the range [0, 2].

Parameters

index

number

Coordinate index.

value

number

Coordinate value.

Returns

this


setCoord()

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

Sets the specified coordinates of the point.

Parameters

x?

number

X coordinate of 3D point.

y?

number

Y coordinate of 3D point.

z?

number

Z coordinate of 3D point.

Returns

this


setX()

‍setX(x): this

Sets the X coordinate of the point.

Parameters

x

number

X coordinate.

Returns

this


setY()

‍setY(y): this

Sets the Y coordinate of the point.

Parameters

y

number

Y coordinate.

Returns

this


setZ()

‍setZ(z): this

Sets the Z coordinate of the point.

Parameters

z

number

Z coordinate.

Returns

this


squareDistance()

‍squareDistance(other): number

Returns the squared distance between this point and other.

Parameters

other

Point

Other point.

Returns

number


subtract()

‍subtract(other): this

Subtracts the coordinates of other from this point.

Parameters

other

Vector

Other vector.

Returns

this


subtracted()

Call Signature

‍subtracted(other): Point

Returns a new point resulting from subtracting other from this point.

Parameters

other

Vector

Other vector.

Returns

Point

Call Signature

‍subtracted(other): Vector

Returns the vector from other to this point.

Parameters

other

Point

Other point.

Returns

Vector


toJSON()

‍toJSON(): BaseXYZ

Returns the JSON representation of this point.

Returns

BaseXYZ


toString()

‍toString(precision?): string

Returns a string representation of this point with the provided precision.

Parameters

precision?

number = 3

Precision.

Returns

string


transform()

‍transform(transformation): this

Transforms this point according to transformation.

Parameters

transformation

Transformation

Transformation.

Returns

this


transformed()

‍transformed(transformation): Point

Returns a new point resulting from transforming this point.

Parameters

transformation

Transformation

Transformation.

Returns

Point


translate()

‍translate(vector): this

Translates this point by vector.

Parameters

vector

Vector

Translation vector.

Returns

this


translated()

‍translated(vector): Point

Returns a new point resulting from translating this point.

Parameters

vector

Vector

Translation vector.

Returns

Point