public class Point2D extends Object implements ICloneable
(x, y)
.Constructor and Description |
---|
Point2D()
Creates a new instance that is located at
(0, 0) . |
Point2D(double x,
double y)
Creates a new instance at the given location.
|
Modifier and Type | Method and Description |
---|---|
Point2D |
clone()
Creates a new instance of this class that has the same values as this objects.
|
double |
distance(double px,
double py)
Calculates the distance between this points and another one, given as its coordinates.
|
static double |
distance(double x1,
double y1,
double x2,
double y2)
Calculates the distance between two points, given as their coordinates.
|
double |
distance(Point2D p)
Calculates the distance between this points and another one.
|
double |
distanceSq(double px,
double py)
Calculates the squared distance between this points and another one, given as its coordinates.
|
static double |
distanceSq(double x1,
double y1,
double x2,
double y2)
Calculates the squared distance between two points, given as their coordinates.
|
double |
distanceSq(Point2D p)
Calculates the squared distance between this points and another one.
|
boolean |
equals(Object obj)
Returns whether this point and
obj are equal. |
double |
getX()
Gets the x coordinate of this point.
|
double |
getY()
Gets the y coordinate of this point.
|
int |
hashCode() |
void |
setLocation(double x,
double y)
Sets the location of this point to the given coordinates.
|
void |
setLocation(Point2D value)
Sets the location of this point to the same values as for the given point.
|
String |
toString() |
public Point2D()
(0, 0)
.public Point2D(double x, double y)
x
- The x coordinate of the new pointy
- The x coordinate of the new pointpublic Point2D clone()
clone
in interface ICloneable
clone
in class Object
Object.clone()
public double distance(double px, double py)
px
- The x coordinate of the second point.py
- The y coordinate of the second point.public static final double distance(double x1, double y1, double x2, double y2)
x1
- The x coordinate of the first point.y1
- The y coordinate of the first point.x2
- The x coordinate of the second point.y2
- The y coordinate of the second point.public double distance(Point2D p)
p
- The second point.public double distanceSq(double px, double py)
px
- The x coordinate of the second point.py
- The y coordinate of the second point.public static final double distanceSq(double x1, double y1, double x2, double y2)
x1
- The x coordinate of the first point.y1
- The y coordinate of the first point.x2
- The x coordinate of the second point.y2
- The y coordinate of the second point.public double distanceSq(Point2D p)
p
- The second point.public boolean equals(Object obj)
obj
are equal.
Two points are considered equal if the have the same location.
public double getX()
public double getY()
public void setLocation(double x, double y)
x
- the new x coordinatey
- the new y coordinatepublic void setLocation(Point2D value)
value
- point whose coordinates are used