rl.common.mapping
Class IdealHex
java.lang.Object
rl.common.mapping.IdealHex
public class IdealHex
- extends java.lang.Object
|
Method Summary |
static void |
ensureCacheSize(int width,
int height)
Ensures that the cache will be at least the specified dimensions. |
static IdealHex |
get(Coordinate Coordinate)
Gets a hex from the cache, if it exists in the cache. |
boolean |
isIntersectedBy(double x0,
double y0,
double x1,
double y1)
Returns true if this hex is intersected by the line |
static int |
turns(double x0,
double y0,
double x1,
double y1,
double x2,
double y2)
Tests whether a line intersects a point or the point passes
to the left or right of the line. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LEFT
public static final int LEFT
- See Also:
- Constant Field Values
STRAIGHT
public static final int STRAIGHT
- See Also:
- Constant Field Values
RIGHT
public static final int RIGHT
- See Also:
- Constant Field Values
x
public double[] x
y
public double[] y
cx
public double cx
cy
public double cy
IdealHex
public IdealHex(Coordinate c)
isIntersectedBy
public boolean isIntersectedBy(double x0,
double y0,
double x1,
double y1)
- Returns true if this hex is intersected by the line
turns
public static int turns(double x0,
double y0,
double x1,
double y1,
double x2,
double y2)
- Tests whether a line intersects a point or the point passes
to the left or right of the line.
Deals with floating point imprecision. Thx deadeye00 (Derek Evans)
ensureCacheSize
public static void ensureCacheSize(int width,
int height)
- Ensures that the cache will be at least the specified dimensions. If it
is not, a new cache is created. Hopefully this won't happen too much.
Must be called at least once before get(), since the initial size is 0.
get
public static IdealHex get(Coordinate Coordinate)
- Gets a hex from the cache, if it exists in the cache. If the hex is not
cached yet, creates it. If the cache is too small, does not resize it.