Class S2Predicates.CompareDistances

  • Enclosing class:
    S2Predicates

    static class S2Predicates.CompareDistances
    extends java.lang.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 < BX, A == B, or AX > BX respectively, and may return 0 if the result is indeterminate.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CompareDistances()
      No instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int exact​(BigPoint x, BigPoint a, BigPoint b)
      Returns a BigDecimal-based test result, which is slow but handle all input.
      static int exact​(S2Point x, S2Point a, S2Point b)
      Returns a BigDecimal-based test result, which is slow but handle all input.
      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.
      static int triageCos​(S2Point x, S2Point a, S2Point b)
      Returns a cosine-based test result.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CompareDistances

        private CompareDistances()
        No instantiation.
    • Method Detail

      • 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.