Class S2Predicates.CompareEdgeDistance

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

static class S2Predicates.CompareEdgeDistance extends Object
A test to compare the distance from point X to edge A with a previously computed distance. When doing many edge distance tests, this saves a lot of work over computing exact distances only to throw them away most of them.

Does not offer generally correct results for all inputs, so that multiple strategies may be implemented for different classes of input.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    No instantiation.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    exact(S2Point x, S2Point a, S2Point b, double r2)
    Returns a BigDecimal-based test result, which is exact but very slow.
    (package private) static int
    exactLineEndpoints(S2Point x, S2Point a, S2Point b, double r2)
    Returns a BigDecimal-based test result assuming the projection of X is onto A or B.
    (package private) static int
    Returns a BigDecimal-based test assuming the projection of "x" is between A and B.
    static int
    triage(S2Point x, S2Point a, S2Point b, double r2)
    Returns -1, 0, or +1 according to whether the distance from the point X to the edge AB is less than, equal to, or greater than "r2" respectively, and may return 0 if the relation is indeterminate.
    (package private) static int
    triageLineCos2(S2Point x, double r2, S2Point n, double n1, double n2)
    Like triageLineSin2, but this method computes the squared cosines of the distances involved.
    (package private) static int
    triageLineEndpoints(S2Point x, S2Point a, S2Point b, double r2)
    Returns the min test result from XA and XB, assuming the projection is A or B.
    (package private) static int
    triageLineInterior(S2Point x, S2Point a, S2Point b, double r2, S2Point n, double n1, double n2)
    Returns the min test result from XA and XB, assuming the projection is between A and B.
    (package private) static int
    triageLineSin2(S2Point x, S2Point a, S2Point b, double r2, S2Point n, double n1, double n2)
    Returns -1, 0, or +1 according to whether the distance from "x" to the great circle through (a, b) is less than, equal to, or greater than the given squared chord length "r2".

    Methods inherited from class java.lang.Object

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

    • CompareEdgeDistance

      private CompareEdgeDistance()
      No instantiation.
  • Method Details

    • triage

      public static int triage(S2Point x, S2Point a, S2Point b, double r2)
      Returns -1, 0, or +1 according to whether the distance from the point X to the edge AB is less than, equal to, or greater than "r2" respectively, and may return 0 if the relation is indeterminate.

      This test uses double arithmetic, which is reasonably precise but allocates a lot.

    • triageLineEndpoints

      static int triageLineEndpoints(S2Point x, S2Point a, S2Point b, double r2)
      Returns the min test result from XA and XB, assuming the projection is A or B.
    • triageLineInterior

      static int triageLineInterior(S2Point x, S2Point a, S2Point b, double r2, S2Point n, double n1, double n2)
      Returns the min test result from XA and XB, assuming the projection is between A and B.
    • triageLineSin2

      static int triageLineSin2(S2Point x, S2Point a, S2Point b, double r2, S2Point n, double n1, double n2)
      Returns -1, 0, or +1 according to whether the distance from "x" to the great circle through (a, b) is less than, equal to, or greater than the given squared chord length "r2". This method computes the squared sines of the distances involved, which is more accurate when the distances are small (less than 45 degrees).

      The remaining parameters are functions of (a, b) and are passed in because they have already been computed: n = (a - b) x (a + b), n1 = n.norm(), and n2 = n.norm2().

    • triageLineCos2

      static int triageLineCos2(S2Point x, double r2, S2Point n, double n1, double n2)
      Like triageLineSin2, but this method computes the squared cosines of the distances involved. It is more accurate when the distances are large (greater than 45 degrees).
    • exact

      public static int exact(S2Point x, S2Point a, S2Point b, double r2)
      Returns a BigDecimal-based test result, which is exact but very slow.
    • exactLineEndpoints

      static int exactLineEndpoints(S2Point x, S2Point a, S2Point b, double r2)
      Returns a BigDecimal-based test result assuming the projection of X is onto A or B.
    • exactLineInterior

      static int exactLineInterior(BigPoint x, BigPoint a, BigPoint b, BigDecimal r2)
      Returns a BigDecimal-based test assuming the projection of "x" is between A and B.