Hide menu
Loading...
Searching...
No Matches
XYZ

Implements 3D coordinate storage and operations.

Implements

Constructors

Constructor

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

Creates coordinates from component values.

If components are omitted, the coordinates are initialized to (0, 0, 0).

Parameters

x?

number

X coordinate.

y?

number

Y coordinate.

z?

number

Z coordinate.

Returns

XYZ

Accessors

x

Get Signature

get x(): number

X coordinate.

Returns

number

Set Signature

set x(x): void

Sets the X coordinate.

Parameters

x

number

X coordinate.

Returns

void

X coordinate.

Implementation of

BaseXYZ.x


y

Get Signature

get y(): number

Y coordinate.

Returns

number

Set Signature

set y(y): void

Sets the Y coordinate.

Parameters

y

number

Y coordinate.

Returns

void

Y coordinate.

Implementation of

BaseXYZ.y


z

Get Signature

get z(): number

Z coordinate.

Returns

number

Set Signature

set z(z): void

Sets the Z coordinate.

Parameters

z

number

Z coordinate.

Returns

void

Z coordinate.

Implementation of

BaseXYZ.z

Methods

add()

add(other): this

Adds other to these coordinates component-wise.

Parameters

other

XYZ

Other coordinates.

Returns

this


added()

added(other): XYZ

Returns a new object resulting from adding other.

Parameters

other

XYZ

Other coordinates.

Returns

XYZ


angle()

angle(other): number

Returns the angle between these coordinates and other.

Returns NaN if either set of coordinates is null.

Parameters

other

XYZ

Other coordinates.

Returns

number


clone()

clone(): XYZ

Creates a new object with the same coordinates.

Returns

XYZ


copy()

copy(other): this

Copies the coordinates of other.

Parameters

other

XYZ

Coordinates to copy.

Returns

this


cross()

cross(other): this

Sets these coordinates to the cross product of these coordinates and other.

Parameters

other

XYZ

Other coordinates.

Returns

this


crossCross()

crossCross(coord1, coord2): this

Computes this = this.cross(coord1.cross(coord2)).

Parameters

coord1

XYZ

First coordinates.

coord2

XYZ

Second coordinates.

Returns

this


crossCrossed()

crossCrossed(coord1, coord2): XYZ

Returns a new object resulting from applying the cross-cross operation.

Parameters

coord1

XYZ

First coordinates.

coord2

XYZ

Second coordinates.

Returns

XYZ


crossed()

crossed(other): XYZ

Returns a new object resulting from taking the cross product with other.

Parameters

other

XYZ

Other coordinates.

Returns

XYZ


divide()

divide(scalar): this

Divides these coordinates by scalar.

Parameters

scalar

number

Scalar value.

Returns

this


divided()

divided(scalar): XYZ

Returns a new object resulting from dividing these coordinates by scalar.

Parameters

scalar

number

Scalar value.

Returns

XYZ


dot()

dot(other): number

Returns the dot product of these coordinates and other.

Parameters

other

XYZ

Other coordinates.

Returns

number


fromXYZ()

static fromXYZ(xyz): XYZ

Creates coordinates from an object implementing the BaseXYZ interface.

Parameters

xyz

BaseXYZ

Object implementing BaseXYZ interface.

Returns

XYZ


get()

get(index): number

Returns the coordinate value:

  • 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 these coordinates are equal to other within the provided tolerance.

Parameters

other

XYZ

Other coordinates.

tolerance?

number = XYZ.coincidenceTolerance

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

Returns

boolean


isNormal()

isNormal(other, tolerance?): boolean

Returns whether other is perpendicular within the provided angular tolerance.

Parameters

other

XYZ

Other coordinates.

tolerance?

number = XYZ.angularTolerance

Angular comparison tolerance (1e-5 by default).

Returns

boolean


isNull()

isNull(): boolean

Returns whether the coordinates are effectively zero within the coincidence tolerance.

Returns

boolean


isOpposite()

isOpposite(other, tolerance?): boolean

Returns whether other is opposite within the provided angular tolerance.

Parameters

other

XYZ

Other coordinates.

tolerance?

number = XYZ.angularTolerance

Angular comparison tolerance (1e-5 by default).

Returns

boolean


isParallel()

isParallel(other, tolerance?): boolean

Returns whether other is parallel within the provided angular tolerance.

Parameters

other

XYZ

Other coordinates.

tolerance?

number = XYZ.angularTolerance

Angular comparison tolerance (1e-5 by default).

Returns

boolean


modulus()

modulus(): number

Returns the modulus of the coordinates.

Returns

number


multiplied()

Call Signature

multiplied(other): XYZ

Returns a new object resulting from multiplying these coordinates by other.

Parameters

other

XYZ

Other coordinates.

Returns

XYZ

Call Signature

multiplied(matrix): XYZ

Returns a new object resulting from multiplying these coordinates by matrix.

Parameters

matrix

Matrix3d

3D matrix.

Returns

XYZ

Call Signature

multiplied(scalar): XYZ

Returns a new object resulting from multiplying these coordinates by scalar.

Parameters

scalar

number

Scalar value.

Returns

XYZ


multiply()

Call Signature

multiply(other): this

Multiplies these coordinates by other component-wise.

Parameters

other

XYZ

Other coordinates.

Returns

this

Call Signature

multiply(matrix): this

Multiplies these coordinates by a 3D matrix.

Parameters

matrix

Matrix3d

3D matrix.

Returns

this

Call Signature

multiply(scalar): this

Multiplies these coordinates by a scalar value.

Parameters

scalar

number

Scalar value.

Returns

this


normalize()

normalize(): this

Normalizes the coordinates.

Null coordinates remain unchanged.

Returns

this


normalized()

normalized(): XYZ

Returns a new object with normalized coordinates.

Returns

XYZ


reverse()

reverse(): this

Reverses the coordinates.

Returns

this


reversed()

reversed(): XYZ

Returns a new object resulting from reversing these coordinates.

Returns

XYZ


set()

set(index, value): this

Sets the coordinate value:

  • 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.

Parameters

x?

number

X coordinate.

y?

number

Y coordinate.

z?

number

Z coordinate.

Returns

this


setX()

setX(x): this

Sets the X coordinate.

Parameters

x

number

X coordinate.

Returns

this


setY()

setY(y): this

Sets the Y coordinate.

Parameters

y

number

Y coordinate.

Returns

this


setZ()

setZ(z): this

Sets the Z coordinate.

Parameters

z

number

Z coordinate.

Returns

this


squareModulus()

squareModulus(): number

Returns the squared modulus of the coordinates.

Returns

number


subtract()

subtract(other): this

Subtracts other from these coordinates component-wise.

Parameters

other

XYZ

Other coordinates.

Returns

this


subtracted()

subtracted(other): XYZ

Returns a new object resulting from subtracting other.

Parameters

other

XYZ

Other coordinates.

Returns

XYZ


toJSON()

toJSON(): BaseXYZ

Returns the JSON representation of the coordinates.

Returns

BaseXYZ


toString()

toString(precision?): string

Returns a string representation of the coordinates with the provided precision.

Parameters

precision?

number = 3

Precision.

Returns

string