public final class Point extends Object
Constructor and Description |
---|
Point(double x,
double y)
Creates a Point object with the given x and y coordinates.
|
Point(double x,
double y,
boolean round)
Creates a Point object with the given x and y coordinates.
|
Modifier and Type | Method and Description |
---|---|
Point |
add(Point other)
Returns the result of addition of the current and the given points.
|
Point |
clone()
Returns a copy of the current point.
|
boolean |
contains(Point other)
Returns
true if the both coordinates of the given point are
less than the corresponding current point coordinates (in absolute
values). |
double |
distanceTo(Point other)
Returns the distance between the current and the given points.
|
Point |
divideBy(double number)
Returns the result of division of the current point by the given number.
|
Point |
divideBy(double number,
boolean round)
Returns the result of division of the current point by the given number.
|
boolean |
equals(Object other)
Returns
true if the given point has the same coordinates. |
Point |
floor()
Returns a copy of the current point with floored coordinates (rounded
down).
|
double |
getX()
Gets the x coordinate.
|
double |
getY()
Gets the y coordinate.
|
Point |
multiplyBy(double number)
Returns the result of multiplication of the current point by the given
number.
|
Point |
round()
Returns a copy of the current point with rounded coordinates.
|
void |
setX(double x)
Sets the x coordinate.
|
void |
setY(double y)
Sets the y coordinate
|
Point |
subtract(Point other)
Returns the result of subtraction of the given point from the current.
|
String |
toString()
Returns a string representation of the point for debugging purposes.
|
public Point(double x, double y)
x
- The x coordinate.y
- The y coordinate.public Point(double x, double y, boolean round)
x
- The x coordinate.y
- The y coordinate.round
- Rounds the x and y value if true
.public double getX()
public void setX(double x)
x
- The x coordinate.public double getY()
public void setY(double y)
y
- The y coordinate.public Point add(Point other)
other
- The given point.public Point subtract(Point other)
other
- The given point.public Point multiplyBy(double number)
number
- The given number.public Point divideBy(double number)
number
- The given number.public Point divideBy(double number, boolean round)
number
- The given number.round
- Rounds the result if true.public double distanceTo(Point other)
other
- The given point.public Point clone()
public Point round()
public Point floor()
public boolean equals(Object other)
true
if the given point has the same coordinates.public boolean contains(Point other)
true
if the both coordinates of the given point are
less than the corresponding current point coordinates (in absolute
values).other
- The other point.true
if the both coordinates of the given
point are less than the corresponding current point coordinates (in
absolute values).Copyright © 2017. All rights reserved.