new Point2d(
x?,y?):Point2d
Creates a point from coordinates.
If coordinates are omitted, the point is created at (0, 0).
number
X coordinate of 2D point.
number
Y coordinate of 2D point.
Point2d
get x():
number
X coordinate of the point.
number
set x(
x):void
Sets the X coordinate of the point.
number
X coordinate.
void
get y():
number
Y coordinate of the point.
number
set y(
y):void
Sets the Y coordinate of the point.
number
Y coordinate.
void
add(
other):this
Adds the coordinates of other to this point.
Other 2D vector.
this
added(
other):Point2d
Returns a new point resulting from adding other to this point.
Other vector.
Point2d
added(
other):Point2d
Returns a new point whose coordinates are the sums of the coordinates of this point and other.
Point2d
Other point.
Point2d
clone():
Point2d
Creates a new point with the same coordinates as this point.
Point2d
copy(
other):this
Copies the coordinates of other to this point.
Point2d
Point to copy.
this
distance(
other):number
Returns the distance between this point and other.
Point2d
Other point.
number
divide(
scalar):this
Divides the coordinates of this point by scalar.
number
Scalar value.
this
divided(
scalar):Point2d
Returns a new point resulting from dividing this point by scalar.
number
Scalar value.
Point2d
staticfromXY(xy):Point2d
Creates a point from an object implementing the BaseXY interface.
Object implementing BaseXY interface.
Point2d
get(
index):number
Returns the coordinate value of the point:
index equals 0index equals 1Throws a RangeError if index is not in the range [0, 1].
number
Coordinate index.
number
isEqual(
other,tolerance?):boolean
Returns whether this point is equal to other within the provided coordinate tolerance.
Point2d
Other 2D point.
number = Point2d.coincidenceTolerance
Coordinate comparison tolerance (1e-9 by default).
boolean
multiplied(
matrix):Point2d
Returns a new point resulting from multiplying this point by matrix.
2D matrix.
Point2d
multiplied(
scalar):Point2d
Returns a new point resulting from multiplying this point by scalar.
number
Scalar value.
Point2d
multiply(
matrix):this
Multiplies the coordinates of this point by a 2D matrix.
2D matrix.
this
multiply(
scalar):this
Multiplies the coordinates of this point by a scalar value.
number
Scalar value.
this
staticorigin():Point2d
Returns a point with coordinates (0, 0).
Point2d
set(
index,value):this
Sets the coordinate value of the point:
index equals 0index equals 1Throws a RangeError if index is not in the range [0, 1].
number
Coordinate index.
number
Coordinate value.
this
setCoord(
x?,y?):this
Sets the specified coordinates of the point.
number
X coordinate of 2D point.
number
Y coordinate of 2D point.
this
setX(
x):this
Sets the X coordinate of the point.
number
X coordinate.
this
setY(
y):this
Sets the Y coordinate of the point.
number
Y coordinate.
this
squareDistance(
other):number
Returns the squared distance between this point and other.
Point2d
Other point.
number
subtract(
other):this
Subtracts the coordinates of other from this point.
Other vector.
this
subtracted(
other):Point2d
Returns a new point resulting from subtracting other from this point.
Other vector.
Point2d
subtracted(
other):Vector2d
Returns the vector from other to this point.
Point2d
Other point.
toJSON():
BaseXY
Returns the JSON representation of this point.
toString(
precision?):string
Returns a string representation of this point with the provided precision.
number = 3
Precision.
string
transform(
transformation):this
Transforms this point according to transformation.
Transformation.
this
transformed(
transformation):Point2d
Returns a new point resulting from transforming this point.
Transformation.
Point2d