Defines direction in 2D space.
new Direction2d(
x
?,y
?):Direction2d
number
X coordinate of 2D direction.
number
Y coordinate of 2D direction.
get x():
number
Returns x coordinate of 2D direction.
number
set x(
x
):void
Sets x coordinate of 2D direction.
number
X coordinate.
void
get y():
number
Returns y coordinate of 2D direction.
number
set y(
y
):void
Sets y coordinate of 2D direction.
number
Y coordinate.
void
add(
other
):this
Adds other
direction coordinates to this
direction coordinates.
Other direction.
this
added(
other
):Direction2d
Returns new Direction2d
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():
Direction2d
Creates new Direction2d
direction with coordinates same as this
.
copy(
other
):this
Copies the coordinates of the other
direction to this
.
Copied object.
this
crossed(
other
):number
Returns cross product of this
and other
directions.
Other direction.
number
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 2D 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
multiplied(
other
):Direction2d
Returns new Direction2d
object with coordinates received by performing a multiply() operation to this
object.
Other direction.
multiplied(
matrix
):Direction2d
Returns new Direction2d
object with coordinates received by performing a multiply() operation to this
object.
2D matrix.
multiply(
other
):this
Multiplies this
direction coordinates with other
direction coordinates.
Other direction.
this
multiply(
matrix
):this
Multiplies this
direction coordinates with matrix
.
2D matrix.
this
reverse():
this
Reverses coordinates of this
direction.
this
reversed():
Direction2d
Returns new Direction2d
object with coordinates received by performing a reverse() operation to this
object.
setCoord(
x
?,y
?):this
Sets x
and y
coordinates of this
object and normalizes these coordinates.
number
X coordinate of 2D direction.
number
Y coordinate of 2D direction.
this
setX(
x
):this
Sets x coordinate of 2D direction.
number
X coordinate.
this
setY(
y
):this
Sets y coordinate of 2D direction.
number
Y coordinate.
this
subtract(
other
):this
Subtracts other
direction coordinates from this
direction coordinates.
Other direction.
this
subtracted(
other
):Direction2d
Returns new Direction2d
object with coordinates received by performing a subtract() operation to this
object.
Other direction.
toJSON():
BaseXY
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
):Direction2d
Returns new Direction2d
object with coordinates received by performing a transform() operation to this
object.
Transformation.
static
fromVector(vector
):Direction2d
Creates new Direction2d
object from Vector2d interface.
2D vector.
static
fromXY(xy
):Direction2d
Creates new Direction2d
object from object implementing BaseXY interface.
Object implementing BaseXY interface.
static
xDir():Direction2d
Returns Direction
with (1, 0)
coordinates.
static
yDir():Direction2d
Returns Direction
with (0, 1)
coordinates.