public final class LatLonPoint2D extends java.lang.Object implements java.lang.Comparable<LatLonPoint2D>
| Modifier and Type | Field and Description |
|---|---|
static java.util.Comparator<LatLonPoint2D> |
LAT_ORDER
Compares two points by x-coordinate.
|
static java.util.Comparator<LatLonPoint2D> |
LON_ORDER
Compares two points by y-coordinate.
|
static java.util.Comparator<LatLonPoint2D> |
R_ORDER
Compares two points by polar radius.
|
| Constructor and Description |
|---|
LatLonPoint2D(double x,
double y)
Initializes a new point (x, y).
|
| Modifier and Type | Method and Description |
|---|---|
static double |
area2(LatLonPoint2D a,
LatLonPoint2D b,
LatLonPoint2D c)
Returns twice the signed area of the triangle a-b-c.
|
java.util.Comparator<LatLonPoint2D> |
atan2Order()
Compares two points by atan2() angle (between –π and π) with respect to this point.
|
static int |
ccw(LatLonPoint2D a,
LatLonPoint2D b,
LatLonPoint2D c)
Returns true if a→b→c is a counterclockwise turn.
|
int |
compareTo(LatLonPoint2D that)
Compares two points by y-coordinate, breaking ties by x-coordinate.
|
double |
distanceSquaredTo(LatLonPoint2D that)
Returns the square of the Euclidean distance between this point and that point.
|
double |
distanceTo(LatLonPoint2D that)
Returns the Euclidean distance between this point and that point.
|
java.util.Comparator<LatLonPoint2D> |
distanceToOrder()
Compares two points by distance to this point.
|
void |
draw()
Plot this point using standard draw.
|
void |
drawTo(LatLonPoint2D that)
Plot a line from this point to that point using standard draw.
|
boolean |
equals(java.lang.Object other)
Compares this point to the specified point.
|
int |
hashCode()
Returns an integer hash code for this point.
|
static void |
main(java.lang.String[] args)
Unit tests the point data type.
|
java.util.Comparator<LatLonPoint2D> |
polarOrder()
Compares two points by polar angle (between 0 and 2π) with respect to this point.
|
double |
r()
Returns the polar radius of this point.
|
double |
theta()
Returns the angle of this point in polar coordinates.
|
java.lang.String |
toString()
Return a string representation of this point.
|
double |
x()
Returns the x-coordinate.
|
double |
y()
Returns the y-coordinate.
|
public static final java.util.Comparator<LatLonPoint2D> LAT_ORDER
public static final java.util.Comparator<LatLonPoint2D> LON_ORDER
public static final java.util.Comparator<LatLonPoint2D> R_ORDER
public LatLonPoint2D(double x,
double y)
x - the x-coordinatey - the y-coordinatejava.lang.IllegalArgumentException - if either x or y
is Double.NaN, Double.POSITIVE_INFINITY or
Double.NEGATIVE_INFINITYpublic static int ccw(LatLonPoint2D a, LatLonPoint2D b, LatLonPoint2D c)
a - first pointb - second pointc - third pointpublic static double area2(LatLonPoint2D a, LatLonPoint2D b, LatLonPoint2D c)
a - first pointb - second pointc - third pointpublic static void main(java.lang.String[] args)
args - the command-line argumentspublic double x()
public double y()
public double r()
public double theta()
public double distanceTo(LatLonPoint2D that)
that - the other pointpublic double distanceSquaredTo(LatLonPoint2D that)
that - the other pointpublic int compareTo(LatLonPoint2D that)
y0 < y1 or if y0 == y1 and x0 < x1.compareTo in interface java.lang.Comparable<LatLonPoint2D>that - the other point0 if this string is equal to the argument
string (precisely when equals() returns true);
a negative integer if this point is less than the argument
point; and a positive integer if this point is greater than the
argument pointpublic java.util.Comparator<LatLonPoint2D> polarOrder()
public java.util.Comparator<LatLonPoint2D> atan2Order()
public java.util.Comparator<LatLonPoint2D> distanceToOrder()
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - the other pointtrue if this point equals other;
false otherwisepublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic void draw()
public void drawTo(LatLonPoint2D that)
that - the other point