Implements 3D coordinate storage and operations.
new XYZ(
x?,y?,z?):XYZ
Creates coordinates from component values.
If components are omitted, the coordinates are initialized to (0, 0, 0).
number
X coordinate.
number
Y coordinate.
number
Z coordinate.
XYZ
get x():
number
X coordinate.
number
set x(
x):void
Sets the X coordinate.
number
X coordinate.
void
X coordinate.
get y():
number
Y coordinate.
number
set y(
y):void
Sets the Y coordinate.
number
Y coordinate.
void
Y coordinate.
get z():
number
Z coordinate.
number
set z(
z):void
Sets the Z coordinate.
number
Z coordinate.
void
Z coordinate.
add(
other):this
Adds other to these coordinates component-wise.
XYZ
Other coordinates.
this
added(
other):XYZ
Returns a new object resulting from adding other.
XYZ
Other coordinates.
XYZ
angle(
other):number
Returns the angle between these coordinates and other.
Returns NaN if either set of coordinates is null.
XYZ
Other coordinates.
number
clone():
XYZ
Creates a new object with the same coordinates.
XYZ
copy(
other):this
Copies the coordinates of other.
XYZ
Coordinates to copy.
this
cross(
other):this
Sets these coordinates to the cross product of these coordinates and other.
XYZ
Other coordinates.
this
crossCross(
coord1,coord2):this
Computes this = this.cross(coord1.cross(coord2)).
XYZ
First coordinates.
XYZ
Second coordinates.
this
crossCrossed(
coord1,coord2):XYZ
Returns a new object resulting from applying the cross-cross operation.
XYZ
First coordinates.
XYZ
Second coordinates.
XYZ
crossed(
other):XYZ
Returns a new object resulting from taking the cross product with other.
XYZ
Other coordinates.
XYZ
divide(
scalar):this
Divides these coordinates by scalar.
number
Scalar value.
this
divided(
scalar):XYZ
Returns a new object resulting from dividing these coordinates by scalar.
number
Scalar value.
XYZ
dot(
other):number
Returns the dot product of these coordinates and other.
XYZ
Other coordinates.
number
staticfromXYZ(xyz):XYZ
Creates coordinates from an object implementing the BaseXYZ interface.
Object implementing BaseXYZ interface.
XYZ
get(
index):number
Returns the coordinate value:
index equals 0index equals 1index equals 2Throws a RangeError if index is not in the range [0, 2].
number
Coordinate index.
number
isEqual(
other,tolerance?):boolean
Returns whether these coordinates are equal to other within the provided tolerance.
XYZ
Other coordinates.
number = XYZ.coincidenceTolerance
Coordinate comparison tolerance (1e-7 by default).
boolean
isNormal(
other,tolerance?):boolean
Returns whether other is perpendicular within the provided angular tolerance.
XYZ
Other coordinates.
number = XYZ.angularTolerance
Angular comparison tolerance (1e-5 by default).
boolean
isNull():
boolean
Returns whether the coordinates are effectively zero within the coincidence tolerance.
boolean
isOpposite(
other,tolerance?):boolean
Returns whether other is opposite within the provided angular tolerance.
XYZ
Other coordinates.
number = XYZ.angularTolerance
Angular comparison tolerance (1e-5 by default).
boolean
isParallel(
other,tolerance?):boolean
Returns whether other is parallel within the provided angular tolerance.
XYZ
Other coordinates.
number = XYZ.angularTolerance
Angular comparison tolerance (1e-5 by default).
boolean
modulus():
number
Returns the modulus of the coordinates.
number
multiplied(
other):XYZ
Returns a new object resulting from multiplying these coordinates by other.
XYZ
Other coordinates.
XYZ
multiplied(
matrix):XYZ
Returns a new object resulting from multiplying these coordinates by matrix.
3D matrix.
XYZ
multiplied(
scalar):XYZ
Returns a new object resulting from multiplying these coordinates by scalar.
number
Scalar value.
XYZ
multiply(
other):this
Multiplies these coordinates by other component-wise.
XYZ
Other coordinates.
this
multiply(
matrix):this
Multiplies these coordinates by a 3D matrix.
3D matrix.
this
multiply(
scalar):this
Multiplies these coordinates by a scalar value.
number
Scalar value.
this
normalize():
this
Normalizes the coordinates.
Null coordinates remain unchanged.
this
normalized():
XYZ
Returns a new object with normalized coordinates.
XYZ
reverse():
this
Reverses the coordinates.
this
reversed():
XYZ
Returns a new object resulting from reversing these coordinates.
XYZ
set(
index,value):this
Sets the coordinate value:
index equals 0index equals 1index equals 2Throws a RangeError if index is not in the range [0, 2].
number
Coordinate index.
number
Coordinate value.
this
setCoord(
x?,y?,z?):this
Sets the specified coordinates.
number
X coordinate.
number
Y coordinate.
number
Z coordinate.
this
setX(
x):this
Sets the X coordinate.
number
X coordinate.
this
setY(
y):this
Sets the Y coordinate.
number
Y coordinate.
this
setZ(
z):this
Sets the Z coordinate.
number
Z coordinate.
this
squareModulus():
number
Returns the squared modulus of the coordinates.
number
subtract(
other):this
Subtracts other from these coordinates component-wise.
XYZ
Other coordinates.
this
subtracted(
other):XYZ
Returns a new object resulting from subtracting other.
XYZ
Other coordinates.
XYZ
toJSON():
BaseXYZ
Returns the JSON representation of the coordinates.
toString(
precision?):string
Returns a string representation of the coordinates with the provided precision.
number = 3
Precision.
string