public final class MapLocation extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<MapLocation>
| Modifier and Type | Field and Description |
|---|---|
float |
x
The x-coordinate.
|
float |
y
The y-coordinate.
|
| Constructor and Description |
|---|
MapLocation(float x,
float y)
Creates a new MapLocation representing the location
with the given coordinates.
|
| Modifier and Type | Method and Description |
|---|---|
MapLocation |
add(Direction direction)
Returns a new MapLocation object representing a location
one unit in distance from this one in the given direction.
|
MapLocation |
add(Direction direction,
float dist)
Returns a new MapLocation object representing a location
dist units away from this one in the given direction. |
MapLocation |
add(float radians)
Returns a new MapLocation object representing a location
one unit in distance from this one in the given direction
represented in radians.
|
MapLocation |
add(float radians,
float dist)
Returns a new MapLocation object representing a location
dist units away from this one in the given direction
represented in radians. |
int |
compareTo(MapLocation other)
A comparison function for MapLocations.
|
Direction |
directionTo(MapLocation location)
Returns the Direction from this MapLocation to
location. |
float |
distanceSquaredTo(MapLocation location)
Computes the squared distance from this location to the specified
location.
|
float |
distanceTo(MapLocation location)
Computes the Euclidean distance from this location to the specified
location.
|
static boolean |
doCirclesCollide(MapLocation center1,
float radius1,
MapLocation center2,
float radius2)
Checks where two given circles collide at any point.
|
boolean |
equals(java.lang.Object obj)
Two MapLocations are regarded as equal iff
their coordinates are the same.
|
int |
hashCode() |
boolean |
isWithinBulletSightRadius(RobotInfo robot)
Determines whether this location is within the bullet sight radius of the
given robot.
|
boolean |
isWithinDistance(MapLocation location,
float dist)
Determines whether this location is within a specified distance
from target location.
|
boolean |
isWithinSensorRadius(RobotInfo robot)
Determines whether this location is within the sensor radius of the
given robot.
|
boolean |
isWithinStrideDistance(RobotInfo robot)
Determines whether this location is within one stride of the given robot.
|
MapLocation |
subtract(Direction direction)
Returns a new MapLocation object representing a location
one unit in distance from this one in the opposite direction
of the given direction.
|
MapLocation |
subtract(Direction direction,
float dist)
Returns a new MapLocation object representing a location
dist units in distance from this one in the opposite direction
of the given direction. |
MapLocation |
subtract(float radians)
Returns a new MapLocation object representing a location
one unit in distance from this one in the opposite direction of the
given direction represented in radians.
|
MapLocation |
subtract(float radians,
float dist)
Returns a new MapLocation object representing a location
dist units in distance from this one in the opposite direction of the
given direction represented in radians. |
java.lang.String |
toString() |
MapLocation |
translate(float dx,
float dy)
Returns a new MapLocation object translated from this location
by a fixed amount.
|
static MapLocation |
valueOf(java.lang.String s) |
public MapLocation(float x,
float y)
x - the x-coordinate of the locationy - the y-coordinate of the locationpublic int compareTo(MapLocation other)
compareTo in interface java.lang.Comparable<MapLocation>other - the MapLocation to compare to.2public boolean equals(java.lang.Object obj)
equals in class java.lang.Object2public int hashCode()
hashCode in class java.lang.Object2public static MapLocation valueOf(java.lang.String s)
public static boolean doCirclesCollide(MapLocation center1, float radius1, MapLocation center2, float radius2)
center1 - the center of the first circleradius1 - the radius of the first circlecenter2 - the center of the second circleradius2 - the radius of the second circle4public java.lang.String toString()
toString in class java.lang.Object2public final float distanceTo(MapLocation location)
location - the location to compute the distance to2public final float distanceSquaredTo(MapLocation location)
location - the location to compute the squared distance to2public final boolean isWithinDistance(MapLocation location, float dist)
location - the location to testdist - the distance for the location to be within2public final boolean isWithinStrideDistance(RobotInfo robot)
robot - the robot to test2public final boolean isWithinSensorRadius(RobotInfo robot)
robot - the robot to test2public final boolean isWithinBulletSightRadius(RobotInfo robot)
robot - the robot to test2public final Direction directionTo(MapLocation location)
location.
If location is null then the return value is null.
If location equals this location then the return value is null.location - The location to which the Direction will be calculatedlocation from this MapLocation.2public final MapLocation add(Direction direction)
direction - the direction to add to this location2public final MapLocation add(float radians)
radians - the radians of the direction to add to this location,
note that 0 radians points right2public final MapLocation add(Direction direction, float dist)
dist units away from this one in the given direction.direction - the direction to add to this locationdist - the distance the locations should be apart2public final MapLocation add(float radians, float dist)
dist units away from this one in the given direction
represented in radians.radians - the radians of the direction to add to this location,
note that 0 radians points rightdist - the distance the locations should be apart2public final MapLocation subtract(Direction direction)
direction - the direction to subtract from this location2public final MapLocation subtract(float radians)
radians - the radians of the direction to subtract from this location,
note that 0 radians points right2public final MapLocation subtract(Direction direction, float dist)
dist units in distance from this one in the opposite direction
of the given direction.direction - the direction to subtract from this locationdist - the distance the locations should be apart2public final MapLocation subtract(float radians, float dist)
dist units in distance from this one in the opposite direction of the
given direction represented in radians.radians - the radians of the direction to subtract from this location,
note that 0 radians points rightdist - the distance the locations should be apart2public final MapLocation translate(float dx, float dy)
dx - the amount to translate in the x directiondy - the amount to translate in the y direction2