Constructor
new Point(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
x |
Number | x-coordinate of the point in 2D Euclidean plane |
y |
Number | y-coordinate of the point in 2D Euclidean plane |
Members
angle
angle of the point made with the positive x-axis from the origin
distance
distance of the point from the origin
slope
slope of the point made with the positive x-axis from the origin
Methods
clone() → {Point}
clone the current point and return a new point object, so that changes made to the original will not affect the clone
Returns:
the cloned point
- Type
- Point
flipX() → {Point}
flip the point horizontally
Returns:
the reflected point
- Type
- Point
flipY() → {Point}
flip the point vertically
Returns:
the reflected point
- Type
- Point
rotate(angle) → {Point}
rotate the point about the origin for the given angle in radian
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
Number | angle to rotate in radian |
Returns:
the rotated point
- Type
- Point
translate(x, y) → {Point}
translate the point by the given amount in x- and y-direction
Parameters:
| Name | Type | Description |
|---|---|---|
x |
Number | amount to displace in the x-direction |
y |
Number | amount to displace in the y-direction |
Returns:
the translated point
- Type
- Point
translateByVector(vector) → {Point}
translate the point by the given vector
Parameters:
| Name | Type | Description |
|---|---|---|
vector |
Vector | the displacement of the point |
Returns:
the translated point
- Type
- Point
update(x, y) → {Point}
update the point to the given coordinates, i.e. change the point to somewhere else
Parameters:
| Name | Type | Description |
|---|---|---|
x |
Number | new x-coordinate of the point |
y |
Number | new y-coordinate of the point |
Returns:
the updated point
- Type
- Point