Constructor
new Point(x, y)
Create a point by its coordinates
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | x-coordinate |
y |
number | y-coordinate |
Members
x
Returns the point x coordinate
x
Sets the point x coordinate
y
Returns the point y coordinate
y
Sets the point y coordinate
Methods
add(other) → {Point}
Add another point to this point
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Point | other point |
Returns:
this point after addition
- Type
- Point
copy() → {Point}
Return a copy of the point
Returns:
copy of the point
- Type
- Point
distance(other) → {number}
Return the distance between two points
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Point | other point |
Returns:
distance between the two points
- Type
- number
equals(other) → {number}
Returns true if the point is equal to another point
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Point | other point |
Returns:
true if the points are equal
- Type
- number
lerp(other, t) → {Point}
Linearly interpolate between this point and another point
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Point | other point |
t |
number | interpolation factor [0, 1] |
Returns:
this point after interpolation
- Type
- Point
multiply(scalar) → {Point}
Multiply this point by a scalar
Parameters:
| Name | Type | Description |
|---|---|---|
scalar |
number | scalar value |
Returns:
this point after multiplication
- Type
- Point
subtract(other) → {Point}
Subtract another point from this point
Parameters:
| Name | Type | Description |
|---|---|---|
other |
Point | other point |
Returns:
this point after subtraction
- Type
- Point
toString() → {string}
Returns the point as a string
Returns:
string representation of the point
- Type
- string