|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--colony.common.MapPoint
Two-dimensional point on a map.
x:
- double // x-coordinate
y:
- double // y-coordinate
Field Summary | |
double |
x
x-coordinate of a two-dimensional map point. |
double |
y
y-coordinate of a two-dimensional map point. |
Constructor Summary | |
MapPoint()
No-arg constructor. |
|
MapPoint(double x,
double y)
The constructor from parameters. |
|
MapPoint(MapPoint p)
Copy constructor. |
Method Summary | |
double |
distanceTo(MapPoint p)
|
boolean |
equals(MapPoint p,
double tolerance)
|
void |
init()
Initialises map point back to the origin. |
boolean |
isWithin(MapPoint p1,
MapPoint p2)
Determines if this is in the rectangle marked by the
parameter p1 and p2 . |
static MapPoint |
parse(String string)
Creates a MapPoint from a String representation following the format in toString() . |
void |
scale(double scale)
Multiplies both the x and y coordinates by the scalar parameter. |
MapPoint |
subtract(MapPoint p)
Returns a new MapPoint which is the difference between this and the parameter. |
String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode |
Field Detail |
public double x
public double y
Constructor Detail |
public MapPoint()
public MapPoint(double x, double y)
x
- initial x-coordinate of this map point.y
- initial y-coordinate of this map point.public MapPoint(MapPoint p)
p
- MapPoint with coordinates to copy.Method Detail |
public double distanceTo(MapPoint p)
public boolean equals(MapPoint p, double tolerance)
p.x == this.x && p.y == this.y
within the
given tolerance. false otherwise.public void init()
public boolean isWithin(MapPoint p1, MapPoint p2)
this
is in the rectangle marked by the
parameter p1
and p2
.
public static MapPoint parse(String string)
toString()
.
public void scale(double scale)
public MapPoint subtract(MapPoint p)
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class Object
|
MIT ACM/IEEE Programming Competition |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |