Package org.locationtech.jts.algorithm
Class ConvexHull.RadialComparator
- java.lang.Object
-
- org.locationtech.jts.algorithm.ConvexHull.RadialComparator
-
- All Implemented Interfaces:
java.util.Comparator
- Enclosing class:
- ConvexHull
private static class ConvexHull.RadialComparator extends java.lang.Object implements java.util.ComparatorComparesCoordinates for their angle and distance relative to an origin.- Version:
- 1.7
-
-
Field Summary
Fields Modifier and Type Field Description private Coordinateorigin
-
Constructor Summary
Constructors Constructor Description RadialComparator(Coordinate origin)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(java.lang.Object o1, java.lang.Object o2)private static intpolarCompare(Coordinate o, Coordinate p, Coordinate q)Given two points p and q compare them with respect to their radial ordering about point o.
-
-
-
Field Detail
-
origin
private Coordinate origin
-
-
Constructor Detail
-
RadialComparator
public RadialComparator(Coordinate origin)
-
-
Method Detail
-
compare
public int compare(java.lang.Object o1, java.lang.Object o2)- Specified by:
comparein interfacejava.util.Comparator
-
polarCompare
private static int polarCompare(Coordinate o, Coordinate p, Coordinate q)
Given two points p and q compare them with respect to their radial ordering about point o. First checks radial ordering. If points are collinear, the comparison is based on their distance to the origin.p < q iff
- ang(o-p) < ang(o-q) (e.g. o-p-q is CCW)
- or ang(o-p) == ang(o-q) && dist(o,p) < dist(o,q)
- Parameters:
o- the originp- a pointq- another point- Returns:
- -1, 0 or 1 depending on whether p is less than, equal to or greater than q
-
-