Constructor
new Point()
Properties:
Name | Type | Description |
---|---|---|
x |
number | X coordinate |
y |
number | Y coordinate |
Classes
Methods
(static) average(…points) → {Point}
Calculates average position of multiple points
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
points |
Point |
<repeatable> |
Points to average |
Returns:
Average point
- Type
- Point
add(other) → {Point}
Returns new point resulting from addition of this and other point.
Parameters:
Name | Type | Description |
---|---|---|
other |
Point | Other point |
Returns:
Resulting Point from addition
- Type
- Point
asArray() → {Array.<number>}
Returns coordinates in array format
Returns:
Array in format [x,y]
- Type
- Array.<number>
asString() → {string}
Returns coordinates in string format
Returns:
Coordinates of the point
- Type
- string
copy() → {Point}
Returns a copy of this instance
Returns:
New instance of Point
- Type
- Point
distanceTo(other) → {number}
Returns distance between the two points
Parameters:
Name | Type | Description |
---|---|---|
other |
Point | 2nd Point |
Returns:
Distance between the points
- Type
- number
rotateAround(origin, angle) → {Point}
Returns new Point resulting from rotating this point around a point of origin by angle
Parameters:
Name | Type | Description |
---|---|---|
origin |
Point | Origin point (around which is this one rotated) |
angle |
number | Angle in radians |
Returns:
New instance of Point resulting from the rotation
- Type
- Point
subtract(other) → {Point}
Returns new point resulting from subtraction of this and other point.
Parameters:
Name | Type | Description |
---|---|---|
other |
Point | Other point |
Returns:
Resulting Point from subtraction
- Type
- Point
xWithin(left, right) → {boolean}
Checks if point is between 2 values on X axis
Parameters:
Name | Type | Description |
---|---|---|
left |
number | Lower value |
right |
number | Higher value |
Returns:
Is within values
- Type
- boolean
yWithin(top, bottom) → {boolean}
Checks if point is between 2 values on Y axis
Parameters:
Name | Type | Description |
---|---|---|
top |
number | Lower value |
bottom |
number | Higher value |
Returns:
Is within values
- Type
- boolean