Class S2Predicates.CompareDistance

java.lang.Object
com.google.common.geometry.S2Predicates.CompareDistance
Enclosing class:
S2Predicates

static class S2Predicates.CompareDistance extends Object
A set of tests to compare the distance XY and a previously computed distance. When doing many distance tests, this saves a lot of work over computing exact distances only to throw away most of them. Each test returns -1 if the distance XY is less than 'r2', +1 if the distance XY is greater than 'r2', and 0 if the distances are exactly equal or the relation is indeterminate.
  • Constructor Details

    • CompareDistance

      private CompareDistance()
      No instantiation.
  • Method Details

    • triageCos

      public static int triageCos(S2Point x, S2Point y, double r2)
      Returns a cosine-based test result. This is the fastest test, it handle all angles, but has a wide margin of uncertainty.
    • triageSin2

      public static int triageSin2(S2Point x, S2Point y, double r2)
      Returns a sine-based test result, which has very good accuracy for small angles, although it only handles angles below 90 degrees.
    • triage

      public static int triage(S2Point x, S2Point y, double r2)
      Returns a test result based on first triageCos(S2Point, S2Point, double) and then triageSin2(S2Point, S2Point, double), so it is fast for any input where exact arithmetic isn't needed.
    • exact

      public static int exact(S2Point x, S2Point y, double r2)
      Calls exact(BigPoint, BigPoint, BigDecimal) with its more precise types.
    • exact

      public static int exact(BigPoint x, BigPoint y, BigDecimal r2)
      Returns a BigDecimal-based test result, which is exact for all inputs but very slow. In particular, this code produces a result as though all points were reprojected to lie exactly on the surface of the unit sphere. It is based on comparing the cosine of the angle XY (when both points are projected to lie exactly on the sphere) to the given threshold.