|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcivquest.util.Coordinate
This class represents one coordinate (x,y) in 2d-space. It uses int-values and supplies functions for comparing coordinates and for performing some basic calculations (like adding another coordinate) on them. The coordinate-values are saved in x,y. These fields are public for convenience (and because you can't do anything wrong with these values). Note that all calculation-functions return NEW Coordinate-objects.
Field Summary | |
int |
x
The x-coordinate. |
int |
y
The y-coordinate. |
Constructor Summary | |
Coordinate()
Constructs a new Coordinate with values (0,0) |
|
Coordinate(java.awt.geom.Dimension2D dimension)
|
|
Coordinate(double x,
double y)
|
|
Coordinate(int nx,
int ny)
Constructs a new Coordinate with values (nx,ny) |
|
Coordinate(java.awt.geom.Point2D point)
|
Method Summary | |
Coordinate |
add(Coordinate oc)
Returns a new Coordinate-object with coordinates (x+oc.x,y+oc.y) |
Coordinate |
add(int xv,
int yv)
Returns a new Coordinate-object with coordinates (x+xv,y+yv) |
java.lang.Object |
clone()
Returns a new Coordinate-object with the same coordinate-values as this one. |
boolean |
equals(Coordinate c)
Returns if this Coordinate has the same values as Coordinate c |
boolean |
equals(int ox,
int oy)
Returns if this Coordinate has values (ox,oy) |
double |
getDistanceTo(Coordinate coord)
Returns the (euklidian) distance between this Coordinate and the given Coordinate. |
Coordinate[] |
getNeighborCoords()
Returns an array with all coordinates that adjust this coordinate (including diagonal adjusting coordinates). |
Coordinate |
mult(Coordinate v)
Returns a new Coordinate-object w = this * v, where * is the standard scalar product |
Coordinate |
mult(double v)
|
Coordinate |
mult(int v)
Returns a new Coordinate-object with coordinates (x*v,y*v) |
void |
set(java.awt.geom.Dimension2D dimension)
|
void |
set(int nx,
int ny)
Sets the coordinate to values (nx,ny) |
void |
set(java.awt.geom.Point2D point)
|
Coordinate |
sub(Coordinate oc)
Returns a new Coordinate-object with coordinates (x-oc.x,y-oc.y) |
Coordinate |
sub(int xv,
int yv)
Returns a new Coordinate-object with coordinates (x-xv,y-yv) |
java.lang.String |
toString()
Returns a String with the coordinate-pair of this Coordinate-object. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int x
public int y
Constructor Detail |
public Coordinate()
public Coordinate(java.awt.geom.Point2D point)
public Coordinate(java.awt.geom.Dimension2D dimension)
public Coordinate(int nx, int ny)
nx
- the new x-coordinateny
- the new y-coordinatepublic Coordinate(double x, double y)
Method Detail |
public void set(int nx, int ny)
nx
- the new x-coordinateny
- the new y-coordinatepublic void set(java.awt.geom.Point2D point)
public void set(java.awt.geom.Dimension2D dimension)
public boolean equals(int ox, int oy)
public boolean equals(Coordinate c)
public java.lang.Object clone()
public Coordinate sub(Coordinate oc)
public Coordinate sub(int xv, int yv)
public Coordinate add(Coordinate oc)
public Coordinate add(int xv, int yv)
public Coordinate mult(int v)
public Coordinate mult(double v)
public Coordinate mult(Coordinate v)
public java.lang.String toString()
public Coordinate[] getNeighborCoords()
public double getDistanceTo(Coordinate coord)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |