Defines direction in 3D space.
new Direction(
x?,y?,z?):Direction
number
X coordinate of 3D direction.
number
Y coordinate of 3D direction.
number
Z coordinate of 3D direction.
get x():
number
Returns x coordinate of 3D direction.
number
set x(
x):void
Sets x coordinate of 3D direction.
number
X coordinate.
void
get y():
number
Returns y coordinate of 3D direction.
number
set y(
y):void
Sets y coordinate of 3D direction.
number
Y coordinate.
void
get z():
number
Returns z coordinate of 3D direction.
number
set z(
z):void
Sets z coordinate of 3D direction.
number
Z coordinate.
void
add(
other):this
Adds other direction coordinates to this direction coordinates.
Other direction.
this
added(
other):Direction
Returns new Direction object with coordinates received by performing a add() operation to this object.
Other direction.
angle(
other):number
Returns angle between this and other directions.
Other direction.
number
clone():
Direction
Creates new Direction direction with coordinates same as this.
copy(
other):this
Copies the coordinates of the other direction to this.
Copied object.
this
cross(
other):this
Sets coordinates of this point as cross product of this and other directions.
Other direction.
this
crossCross(
coord1,coord2):this
Computes this = this.cross(coord1.cross(coord2)).
First direction.
Second direction.
this
crossCrossed(
coord1,coord2):Direction
Returns new Direction object with coordinates received by performing a crossCross() operation to this object.
First direction.
Second direction.
crossed(
other):Direction
Returns new Direction object with coordinates received by performing a cross() operation to this object.
Other direction.
dot(
other):number
Returns dot product of this and other directions.
Other direction.
number
isEqual(
other,tolerance?):boolean
Returns true if other direction are equal to this direction within provided tolerance (1e-7 by default). Returns false otherwise.
Other 3D direction.
number
Angular comparison tolerance;
boolean
isNormal(
other,tolerance?):boolean
Returns true if other direction is perpendicular to this within provided tolerance (1e-7 by default).
Other direction.
number
boolean
isOpposite(
other,tolerance?):boolean
Returns true if other direction is opposite to this within provided tolerance (1e-7 by default).
Other direction.
number
boolean
isParallel(
other,tolerance?):boolean
Returns true if other direction is parallel to this within provided tolerance (1e-7 by default).
Other direction.
number
boolean
mirror(
direction):this
Mirrors this 3D direction relative to other direction.
Other direction.
this
mirror(
axis):this
Mirrors this 3D point relative to axis.
Axis.
this
mirror(
axis):this
Mirrors this 3D point relative to axis.
Axis.
this
mirrored(
direction):Direction
Returns new Direction object with coordinates received by performing a mirror() operation to this object.
Direction.
mirrored(
axis):Direction
Returns new Direction object with coordinates received by performing a mirror() operation to this object.
Axis.
mirrored(
axis):Direction
Returns new Direction object with coordinates received by performing a mirror() operation to this object.
Axis.
multiplied(
other):Direction
Returns new Direction object with coordinates received by performing a multiply() operation to this object.
Other direction.
multiplied(
matrix):Direction
Returns new Direction object with coordinates received by performing a multiply() operation to this object.
3D matrix.
multiply(
other):this
Multiplies this direction coordinates with other direction coordinates.
Other direction.
this
multiply(
matrix):this
Multiplies this direction coordinates with matrix.
3D matrix.
this
reverse():
this
Reverses coordinates of this direction.
this
reversed():
Direction
Returns new Direction object with coordinates received by performing a reverse() operation to this object.
rotate(
axis,angle):this
Rotates this 3D direction around axis on angle.
Rotation axis.
number
Rotation angle.
this
rotated(
axis,angle):Direction
Returns new Direction object with coordinates received by performing a rotate() operation to this object.
Rotation axis.
number
Rotation angle.
setCoord(
x?,y?,z?):this
Sets x and y coordinates of this object and normalizes these coordinates.
number
X coordinate of 3D direction.
number
Y coordinate of 3D direction.
number
this
setX(
x):this
Sets x coordinate of 3D direction.
number
X coordinate.
this
setY(
y):this
Sets y coordinate of 3D direction.
number
Y coordinate.
this
setZ(
z):this
Sets z coordinate of 3D direction.
number
Z coordinate.
this
subtract(
other):this
Subtracts other direction coordinates from this direction coordinates.
Other direction.
this
subtracted(
other):Direction
Returns new Direction object with coordinates received by performing a subtract() operation to this object.
Other direction.
toJSON():
BaseXYZ
Returns JSON representation of this direction.
toString(
precision):string
Returns string representation of this direction with provided precision (3 by default).
number = 3
Precision.
string
transform(
transformation):this
Transforms coordinates of this direction according to transformation.
Transformation.
this
transformed(
transformation):Direction
Returns new Direction object with coordinates received by performing a transform() operation to this object.
Transformation.
staticfromVector(vector):Direction
Creates new Direction object from Vector.
3D vector.
staticfromXYZ(xyz):Direction
Creates new Direction object from object implementing BaseXYZ interface.
Object implementing BaseXYZ interface.
staticxDir():Direction
Returns Direction with (1, 0, 0) coordinates.
staticyDir():Direction
Returns Direction with (0, 1, 0) coordinates.
staticzDir():Direction
Returns Direction with (0, 0, 1) coordinates.