public final class Double2D
extends java.lang.Object
implements java.io.Serializable
One day in the far future, Double3D 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.
Double2D.equals(...) can compare by value against other Int2Ds and Double2Ds.
Constructor and Description |
---|
Double2D() |
Double2D(double x,
double y) |
Double2D(Int2D p) |
Double2D(MutableDouble2D p) |
Double2D(MutableInt2D p) |
Double2D(java.awt.Point p) |
Double2D(java.awt.geom.Point2D.Double p) |
Double2D(java.awt.geom.Point2D.Float p) |
Double2D(java.awt.geom.Point2D p)
Only included for completeness' sakes, in case a new Point2D subclass is created in the future.
|
Modifier and Type | Method and Description |
---|---|
Double2D |
add(Double2D other) |
double |
angle()
Returns the length of the vector between -Pi and Pi.
|
double |
distance(Double2D p)
Returns the distance FROM this Double2D TO the specified point.
|
double |
distance(double x,
double y)
Returns the distance FROM this Double2D TO the specified point
|
double |
distance(Int2D p)
Returns the distance FROM this Double2D TO the specified point.
|
double |
distance(MutableInt2D p)
Returns the distance FROM this Double2D TO the specified point.
|
double |
distance(java.awt.geom.Point2D p)
Returns the distance FROM this Double2D TO the specified point.
|
double |
distanceSq(Double2D p)
Returns the distance FROM this Double2D TO the specified point.
|
double |
distanceSq(double x,
double y)
Returns the distance FROM this Double2D TO the specified point
|
double |
distanceSq(Int2D p)
Returns the distance FROM this Double2D TO the specified point.
|
double |
distanceSq(MutableInt2D p)
Returns the distance FROM this Double2D TO the specified point.
|
double |
distanceSq(java.awt.geom.Point2D p)
Returns the distance FROM this Double2D TO the specified point
|
double |
dot(Double2D other)
Takes the dot product this Double2D with another
|
boolean |
equals(java.lang.Object obj) |
double |
getX() |
double |
getY() |
int |
hashCode() |
double |
length()
Returns the vector length of the Double2D
|
double |
lengthSq()
Returns the vector length of the Double2D
|
double |
manhattanDistance(Double2D p)
Returns the manhtattan distance FROM this Double2D TO the specified point
|
double |
manhattanDistance(double x,
double y)
Returns the manhtattan distance FROM this Double2D TO the specified point
|
double |
manhattanDistance(Int2D p)
Returns the manhtattan distance FROM this Double2D TO the specified point
|
double |
manhattanDistance(MutableDouble2D p)
Returns the manhtattan distance FROM this Double2D TO the specified point
|
double |
manhattanDistance(MutableInt2D p)
Returns the manhtattan distance FROM this Double2D TO the specified point
|
double |
manhattanDistance(java.awt.geom.Point2D p)
Returns the manhtattan distance FROM this Double2D TO the specified point
|
Double2D |
multiply(double val)
Multiplies each element by scalar "val"
|
Double2D |
negate()
Returns the negation of this Double2D.
|
Double2D |
normalize()
Normalizes the vector (sets its length to 1).
|
double |
perpDot(Double2D other)
2D version of the cross product.
|
Double2D |
resize(double dist)
Scales the vector to length "dist".
|
Double2D |
rotate(double theta)
Rotates the Double2D by theta radians
|
Double2D |
subtract(Double2D other)
Subtracts Double2D "other" from current Double2D using
vector subtraction
|
java.lang.String |
toCoordinates() |
java.awt.geom.Point2D.Double |
toPoint2D() |
java.lang.String |
toString() |
public Double2D()
public Double2D(Int2D p)
public Double2D(MutableInt2D p)
public Double2D(MutableDouble2D p)
public Double2D(java.awt.Point p)
public Double2D(java.awt.geom.Point2D.Double p)
public Double2D(java.awt.geom.Point2D.Float p)
public Double2D(java.awt.geom.Point2D p)
public Double2D(double x, double y)
public final double getX()
public final double getY()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toCoordinates()
public java.awt.geom.Point2D.Double toPoint2D()
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(Int2D p)
public double distance(MutableInt2D p)
public double distance(java.awt.geom.Point2D p)
public double distanceSq(double x, double y)
public double distanceSq(Double2D p)
public double distanceSq(Int2D p)
public double distanceSq(MutableInt2D p)
public double distanceSq(java.awt.geom.Point2D p)
public double manhattanDistance(double x, double y)
public double manhattanDistance(Double2D p)
public double manhattanDistance(Int2D p)
public double manhattanDistance(MutableDouble2D p)
public double manhattanDistance(MutableInt2D p)
public double manhattanDistance(java.awt.geom.Point2D p)
public final Double2D subtract(Double2D other)
public final double length()
public final double angle()
public final double lengthSq()
public final Double2D multiply(double val)
public final Double2D resize(double dist)
public final Double2D normalize()
public final double dot(Double2D other)
public double perpDot(Double2D other)
public final Double2D negate()
public final Double2D rotate(double theta)