Package ucar.unidata.data.point
Class LatLonPoint2D
java.lang.Object
ucar.unidata.data.point.LatLonPoint2D
- All Implemented Interfaces:
Comparable<LatLonPoint2D>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator
<LatLonPoint2D> Compares two points by x-coordinate.static final Comparator
<LatLonPoint2D> Compares two points by y-coordinate.static final Comparator
<LatLonPoint2D> Compares two points by polar radius. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
area2
(LatLonPoint2D a, LatLonPoint2D b, LatLonPoint2D c) Returns twice the signed area of the triangle a-b-c.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
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.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
Compares this point to the specified point.int
hashCode()
Returns an integer hash code for this point.static void
Unit tests the point data type.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.toString()
Return a string representation of this point.double
x()
Returns the x-coordinate.double
y()
Returns the y-coordinate.
-
Field Details
-
LAT_ORDER
Compares two points by x-coordinate. -
LON_ORDER
Compares two points by y-coordinate. -
R_ORDER
Compares two points by polar radius.
-
-
Constructor Details
-
LatLonPoint2D
public LatLonPoint2D(double x, double y) Initializes a new point (x, y).- Parameters:
x
- the x-coordinatey
- the y-coordinate- Throws:
IllegalArgumentException
- if eitherx
ory
isDouble.NaN
,Double.POSITIVE_INFINITY
orDouble.NEGATIVE_INFINITY
-
-
Method Details
-
ccw
Returns true if a→b→c is a counterclockwise turn.- Parameters:
a
- first pointb
- second pointc
- third point- Returns:
- { -1, 0, +1 } if a→b→c is a { clockwise, collinear; counterclocwise } turn.
-
area2
Returns twice the signed area of the triangle a-b-c.- Parameters:
a
- first pointb
- second pointc
- third point- Returns:
- twice the signed area of the triangle a-b-c
-
main
Unit tests the point data type.- Parameters:
args
- the command-line arguments
-
x
public double x()Returns the x-coordinate.- Returns:
- the x-coordinate
-
y
public double y()Returns the y-coordinate.- Returns:
- the y-coordinate
-
r
public double r()Returns the polar radius of this point.- Returns:
- the polar radius of this point in polar coordiantes: sqrt(x*x + y*y)
-
theta
public double theta()Returns the angle of this point in polar coordinates.- Returns:
- the angle (in radians) of this point in polar coordiantes (between –π and π)
-
distanceTo
Returns the Euclidean distance between this point and that point.- Parameters:
that
- the other point- Returns:
- the Euclidean distance between this point and that point
-
distanceSquaredTo
Returns the square of the Euclidean distance between this point and that point.- Parameters:
that
- the other point- Returns:
- the square of the Euclidean distance between this point and that point
-
compareTo
Compares two points by y-coordinate, breaking ties by x-coordinate. Formally, the invoking point (x0, y0) is less than the argument point (x1, y1) if and only if eithery0 < y1
or ify0 == y1
andx0 < x1
.- Specified by:
compareTo
in interfaceComparable<LatLonPoint2D>
- Parameters:
that
- the other point- Returns:
- the value
0
if this string is equal to the argument string (precisely whenequals()
returnstrue
); a negative integer if this point is less than the argument point; and a positive integer if this point is greater than the argument point
-
polarOrder
Compares two points by polar angle (between 0 and 2π) with respect to this point.- Returns:
- the comparator
-
atan2Order
Compares two points by atan2() angle (between –π and π) with respect to this point.- Returns:
- the comparator
-
distanceToOrder
Compares two points by distance to this point.- Returns:
- the comparator
-
equals
Compares this point to the specified point. -
toString
Return a string representation of this point. -
hashCode
public int hashCode()Returns an integer hash code for this point. -
draw
public void draw()Plot this point using standard draw. -
drawTo
Plot a line from this point to that point using standard draw.- Parameters:
that
- the other point
-