| Constructor and Description |
|---|
Coord(double x,
double y)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
angle(Coord other)
Returns the angle (in radians) from this coord to the given coord
|
Coord |
clone()
Returns a clone of this coordinate
|
int |
compareTo(Coord other)
Compares this coordinate to other coordinate.
|
double |
distance(Coord other)
Returns the distance to another coordinate
|
double |
distance2(Coord other)
Returns the square of the distance to another coordinate
|
boolean |
equals(Coord c)
Checks if this coordinate's location is equal to other coordinate's
|
boolean |
equals(java.lang.Object o) |
double |
getX()
Returns the x coordinate
|
double |
getY()
Returns the y coordinate
|
int |
hashCode()
Returns a hash code for this coordinate
(actually a hash of the String made of the coordinates)
|
void |
setLocation(Coord c)
Sets this coordinate's location to be equal to other
coordinates location
|
void |
setLocation(double x,
double y)
Sets the location of this coordinate object
|
java.lang.String |
toString()
Returns a text representation of the coordinate (rounded to 2 decimals)
|
void |
translate(double dx,
double dy)
Moves the point by dx and dy
|
public Coord(double x,
double y)
x - Initial X-coordinatey - Initial Y-coordinatepublic void setLocation(double x,
double y)
x - The x coordinate to sety - The y coordinate to setpublic void setLocation(Coord c)
c - The other coordinatepublic void translate(double dx,
double dy)
dx - How much to move the point in X-directiondy - How much to move the point in Y-directionpublic double distance(Coord other)
other - The other coordinatepublic double distance2(Coord other)
other - The other coordinatepublic double angle(Coord other)
other - The other coordinatepublic double getX()
public double getY()
public java.lang.String toString()
toString in class java.lang.Objectpublic Coord clone()
clone in class java.lang.Objectpublic boolean equals(Coord c)
c - The other coordinatepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(Coord other)
compareTo in interface java.lang.Comparable<Coord>