Class S2Predicates.CompareDistances

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

static class S2Predicates.CompareDistances extends Object
A set of tests to determine which of two points is closer to a reference point. Generally much faster then computing even one exact distance, since most points are "obviously" ordered w.r.t. the reference point. Returns -1, 0, or +1 according to whether AX invalid input: '<' BX, A == B, or AX > BX respectively, and may return 0 if the result is indeterminate.
  • Constructor Details

    • CompareDistances

      private CompareDistances()
      No instantiation.
  • Method Details

    • triageCos

      public static int triageCos(S2Point x, S2Point a, S2Point b)
      Returns a cosine-based test result. It handles all angles, is the fastest implementation, but has a wide margin of uncertainty.
    • triageSin2

      public static int triageSin2(S2Point x, S2Point a, S2Point b)
      Returns the test result using a more accurate sine strategy, which only allows angles either both below -90 or both above +90 degrees.
    • exact

      public static int exact(S2Point x, S2Point a, S2Point b)
      Returns a BigDecimal-based test result, which is slow but handle all input.
    • exact

      public static int exact(BigPoint x, BigPoint a, BigPoint b)
      Returns a BigDecimal-based test result, which is slow but handle all input.
    • sos

      public static int sos(S2Point a, S2Point b)
      Given that the exact test returned 0, returns a Simulation of Simplicity symbolic perturbation-based test result to select a consistent non-zero result.