public final class Int2D
extends java.lang.Object
implements java.io.Serializable
One day in the far future, Int2D should also be HIGHLY efficient; since it is immutable, it can be passed by value rather than by pointer by a smart compiler. Not today, though. But it's not bad.
This class has an elaborate hash code generation that is much more random than Sun's standard generator, but takes more time. For very large numbers of objects, this is a good idea, but we may change it to a simpler version in the future.
Int2D.equals(...) can compare by value against other Int2Ds, MutableInt2Ds, Double2Ds, and MutableDouble2Ds.
Constructor and Description |
---|
Int2D() |
Int2D(int x,
int y) |
Int2D(MutableInt2D p) |
Int2D(java.awt.Point p) |
Modifier and Type | Method and Description |
---|---|
double |
distance(Double2D p)
Returns the distance FROM this Int2D TO the specified point.
|
double |
distance(double x,
double y)
Returns the distance FROM this Int2D TO the specified point
|
double |
distance(Int2D p)
Returns the distance FROM this Int2D TO the specified point.
|
double |
distance(MutableInt2D p)
Returns the distance FROM this Int2D TO the specified point.
|
double |
distance(java.awt.geom.Point2D p)
Returns the distance FROM this Int2D TO the specified point.
|
double |
distanceSq(Double2D p)
Returns the squared distance FROM this Int2D TO the specified point.
|
double |
distanceSq(double x,
double y)
Returns the squared distance FROM this Int2D TO the specified point
|
double |
distanceSq(Int2D p)
Returns the squared distance FROM this Int2D TO the specified point.
|
double |
distanceSq(MutableInt2D p)
Returns the squared distance FROM this Int2D TO the specified point.
|
double |
distanceSq(java.awt.geom.Point2D p)
Returns the squared distance FROM this Int2D TO the specified point
|
boolean |
equals(java.lang.Object obj) |
int |
getX() |
int |
getY() |
int |
hashCode() |
long |
manhattanDistance(Int2D p)
Returns the manhattan distance FROM this Int2D TO the specified point.
|
long |
manhattanDistance(int x,
int y)
Returns the manhattan distance FROM this Int2D TO the specified point.
|
long |
manhattanDistance(MutableInt2D p)
Returns the manhattan distance FROM this Int2D TO the specified point.
|
long |
manhattanDistance(java.awt.Point p)
Returns the manhattan distance FROM this Int2D TO the specified point.
|
java.lang.String |
toCoordinates() |
java.awt.Point |
toPoint() |
java.awt.geom.Point2D.Double |
toPoint2D() |
java.lang.String |
toString() |
public Int2D()
public Int2D(java.awt.Point p)
public Int2D(MutableInt2D p)
public Int2D(int x, int y)
public final int getX()
public final int getY()
public java.awt.geom.Point2D.Double toPoint2D()
public java.awt.Point toPoint()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toCoordinates()
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public double distance(double x, double y)
public double distance(Double2D p)
public double distance(MutableInt2D p)
public double distance(Int2D p)
public double distance(java.awt.geom.Point2D p)
public double distanceSq(double x, double y)
public double distanceSq(Double2D p)
public double distanceSq(java.awt.geom.Point2D p)
public double distanceSq(MutableInt2D p)
public double distanceSq(Int2D p)
public long manhattanDistance(int x, int y)
public long manhattanDistance(MutableInt2D p)
public long manhattanDistance(Int2D p)
public long manhattanDistance(java.awt.Point p)