Methods Summary |
---|
public java.lang.Object | clone()Creates a new object of the same class and with the
same contents as this object.
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
|
public double | distance(double px, double py)Returns the distance from this Point2D to
a specified point.
px -= getX();
py -= getY();
return Math.sqrt(px * px + py * py);
|
public double | distance(java.awt.geom.Point2D pt)Returns the distance from this Point2D to a
specified Point2D .
double px = pt.getX() - this.getX();
double py = pt.getY() - this.getY();
return Math.sqrt(px * px + py * py);
|
public static double | distance(double x1, double y1, double x2, double y2)Returns the distance between two points.
x1 -= x2;
y1 -= y2;
return Math.sqrt(x1 * x1 + y1 * y1);
|
public static double | distanceSq(double x1, double y1, double x2, double y2)Returns the square of the distance between two points.
x1 -= x2;
y1 -= y2;
return (x1 * x1 + y1 * y1);
|
public double | distanceSq(double px, double py)Returns the square of the distance from this
Point2D to a specified point.
px -= getX();
py -= getY();
return (px * px + py * py);
|
public double | distanceSq(java.awt.geom.Point2D pt)Returns the square of the distance from this
Point2D to a specified Point2D .
double px = pt.getX() - this.getX();
double py = pt.getY() - this.getY();
return (px * px + py * py);
|
public boolean | equals(java.lang.Object obj)Determines whether or not two points are equal. Two instances of
Point2D are equal if the values of their
x and y member fields, representing
their position in the coordinate space, are the same.
if (obj instanceof Point2D) {
Point2D p2d = (Point2D) obj;
return (getX() == p2d.getX()) && (getY() == p2d.getY());
}
return super.equals(obj);
|
public abstract double | getX()Returns the X coordinate of this Point2D in
double precision.
|
public abstract double | getY()Returns the Y coordinate of this Point2D in
double precision.
|
public int | hashCode()Returns the hashcode for this Point2D .
long bits = java.lang.Double.doubleToLongBits(getX());
bits ^= java.lang.Double.doubleToLongBits(getY()) * 31;
return (((int) bits) ^ ((int) (bits >> 32)));
|
public abstract void | setLocation(double x, double y)Sets the location of this Point2D to the
specified double coordinates.
|
public void | setLocation(java.awt.geom.Point2D p)Sets the location of this Point2D to the same
coordinates as the specified Point2D object.
setLocation(p.getX(), p.getY());
|