new Vector2d(
x
?,y
?):Vector2d
number
X coordinate of 2D vector.
number
Y coordinate of 2D vector.
get x():
number
Returns x coordinate of 2D vector.
number
set x(
x
):void
Sets x coordinate of 2D vector.
number
X coordinate.
void
get y():
number
Returns y coordinate of 2D vector.
number
set y(
y
):void
Sets y coordinate of 2D vector.
number
Y coordinate.
void
add(
other
):this
Adds other
vector coordinates to this
vector coordinates.
Other vector.
this
added(
other
):Vector2d
Returns new Vector2d
object with coordinates received by performing a add() operation to this
object.
Other vector.
angle(
other
):number
Returns angle between this
and other
vectors.
Other vector.
number
clone():
Vector2d
Creates new Vector
object with coordinates same as this
.
copy(
other
):this
Copies the coordinates of the other
vector to this
.
Copied object.
this
crossed(
other
):number
Returns cross product of this
and other
vectors.
Other vector.
number
divide(
scalar
):this
Divide this
vector coordinates by scalar
value.
number
Scalar value.
this
divided(
scalar
):Vector2d
Returns new Vector2d
object with coordinates received by performing a divide() operation to this
object.
number
Scalar value.
dot(
other
):number
Returns dot product of this
and other
vector.
Other vector.
number
isEqual(
other
,tolerance
?):boolean
Returns true
if other
vector coordinates are equal to this
vector coordinated within provided tolerance (1e-7
by default). Returns false
otherwise.
Other 2D vector.
number
Coordinates comparison tolerance;
boolean
isNormal(
other
,tolerance
?):boolean
Returns true
if other
vector is perpendicular to this
within provided tolerance (1e-7
by default).
Other vector.
number
boolean
isOpposite(
other
,tolerance
?):boolean
Returns true
if other
vector is opposite to this
within provided tolerance (1e-7
by default).
Other vector.
number
boolean
isParallel(
other
,tolerance
?):boolean
Returns true
if other
vector is parallel to this
within provided tolerance (1e-7
by default).
Other vector.
number
boolean
length():
number
Returns length of the vector.
number
multiplied(
other
):Vector2d
Returns new Vector2d
object with coordinates received by performing a multiply() operation to this
object.
Other vector.
multiplied(
matrix
):Vector2d
Returns new Vector2d
object with coordinates received by performing a multiply() operation to this
object.
2D matrix.
multiplied(
scalar
):Vector2d
Returns new Vector2d
object with coordinates received by performing a multiply() operation to this
object.
number
Scalar value.
multiply(
other
):this
Multiplies this
vector coordinates with other
vector coordinates.
Other vector.
this
multiply(
matrix
):this
Multiplies this
vector coordinates with 2D matrix.
2D matrix.
this
multiply(
scalar
):this
Multiplies this
vector coordinates with scalar
value.
number
Scalar value.
this
normalize():
this
Normalizes coordinates of this
vector.
this
normalized():
Vector2d
Returns new Vector2d
object with normalized coordinates of this
vector.
reverse():
this
Reverses coordinates of this
vector.
this
reversed():
Vector2d
Returns new Vector2d
object with coordinates received by performing a reverse() operation to this
object.
setCoord(
x
?,y
?):this
Sets x
and y
coordinates of this
object.
number
X coordinate of 2D vector.
number
Y coordinate of 2D vector.
this
setX(
x
):this
Sets x coordinate of 2D vector.
number
X coordinate.
this
setY(
y
):this
Sets y coordinate of 2D vector.
number
Y coordinate.
this
subtract(
other
):this
Subtracts other
vector coordinates from this
vector coordinates.
Other vector.
this
subtracted(
other
):Vector2d
Returns new Vector2d
object with coordinates received by performing a subtract() operation to this
object.
Other vector.
toJSON():
BaseXY
Returns JSON representation of this
vector.
toString(
precision
):string
Returns string representation of this
vector with provided precision (3
by default).
number
= 3
Precision.
string
transform(
transformation
):this
Transforms coordinates of this
vector according to transformation
.
Transformation.
this
transformed(
transformation
):Vector2d
Returns new Vector2d
object with coordinates received by performing a transform() operation to this
object.
Transformation.
static
fromPoints(start
,end
):Vector2d
Creates new Vector2d
object from two points that represents start and end points of the vector.
Start point.
End point.
static
fromXY(xy
):Vector2d
Creates new Vector2d
object from object implementing BaseXY interface.
Object implementing BaseXY interface.