Class ConvexHull.RadialComparator

java.lang.Object
org.locationtech.jts.algorithm.ConvexHull.RadialComparator
All Implemented Interfaces:
Comparator
Enclosing class:
ConvexHull

private static class ConvexHull.RadialComparator extends Object implements Comparator
Compares Coordinates for their angle and distance relative to an origin.
Version:
1.7
  • Field Details

  • Constructor Details

    • RadialComparator

      public RadialComparator(Coordinate origin)
  • Method Details

    • compare

      public int compare(Object o1, Object o2)
      Specified by:
      compare in interface 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 invalid input: '<' q iff

      • ang(o-p) invalid input: '<' ang(o-q) (e.g. o-p-q is CCW)
      • or ang(o-p) == ang(o-q) invalid input: '&'invalid input: '&' dist(o,p) invalid input: '<' dist(o,q)
      Parameters:
      o - the origin
      p - a point
      q - another point
      Returns:
      -1, 0 or 1 depending on whether p is less than, equal to or greater than q