java.lang.Object | +--edu.colorado.geometry.Location
A Location
object keeps track of a location on a two-dimensional
plane.
Constructor Summary | |
Location(double xInitial,
double yInitial)
Construct a Location with specified coordinates. |
Method Summary | |
java.lang.Object |
clone()
Generate a copy of this Location . |
static double |
distance(Location p1,
Location p2)
Compute the distance between two Locations . |
boolean |
equals(java.lang.Object obj)
Compare this Location to another object for equality. |
double |
getX()
Get the x coordinate of this Location . |
double |
getY()
Get the y coordinate of this Location . |
static Location |
midpoint(Location p1,
Location p2)
Generate and return a Location halfway between two others. |
void |
rotate90()
Rotate this Location 90 degrees in a clockwise direction. |
void |
shift(double xAmount,
double yAmount)
Move this Location by given amounts along the x and y axes. |
java.lang.String |
toString()
Generate a String representation of this Location . |
Methods inherited from class java.lang.Object |
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Location(double xInitial, double yInitial)
Location
with specified coordinates.xInitial
- the initial x coordinate of this Location
yInitial
- the initial y coordinate of this Location
Location
has been initialized at the given coordinates.Method Detail |
public java.lang.Object clone()
Location
.-
- noneLocation
. Subsequent
changes to the copy will not affect the original, nor vice versa.
Note that the return value must be typecast to a
Location
before it can be used.public static double distance(Location p1, Location p2)
Locations
.p1
- the first Location
p2
- the second Location
p1
and p2
Double.POSITIVE_INFINITY
if the distance
calculation overflows. The answer is Double.NaN
if either
Location
is null.public boolean equals(java.lang.Object obj)
Location
to another object for equality.obj
- an object with which this Location
will be comparedtrue
indicates that
obj
refers to a
Location
object with the same value as this
Location
. Otherwise the return value is
false
.
obj
is null or does not refer to a
Location
object, then the answer is
false
.public double getX()
Location
.-
- noneLocation
.public double getY()
Location
.-
- noneLocation
.public static Location midpoint(Location p1, Location p2)
Location
halfway between two others.p1
- the first Location
p2
- the second Location
Location
that is halfway between p1
and p2
.
p1
or p2
is null.public void rotate90()
Location
90 degrees in a clockwise direction.-
- none
Location
has been rotated clockwise 90 degrees around
the origin.public void shift(double xAmount, double yAmount)
Location
by given amounts along the x and y axes.xAmount
- the amount to move this Location
along the x axisyAmount
- the amount to move this Location
along the y axis
Location
has been moved by the given amounts along the two axes.
Double.MAX_VALUE
or below -Double.MAX_VALUE
.
In these cases, subsequent activations of getX
or
getY
will return Double.POSITIVE_INFINITY
or
Double.NEGATIVE_INFINITY
.public java.lang.String toString()
Location
.-
- noneLocation