Package com.google.common.geometry
Class S2Predicates.CompareDistance
java.lang.Object
com.google.common.geometry.S2Predicates.CompareDistance
- Enclosing class:
S2Predicates
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
exact
(BigPoint x, BigPoint y, BigDecimal r2) Returns a BigDecimal-based test result, which is exact for all inputs but very slow.static int
Callsexact(BigPoint, BigPoint, BigDecimal)
with its more precise types.static int
Returns a test result based on firsttriageCos(com.google.common.geometry.S2Point, com.google.common.geometry.S2Point, double)
and thentriageSin2(com.google.common.geometry.S2Point, com.google.common.geometry.S2Point, double)
, so it is fast for any input where exact arithmetic isn't needed.static int
Returns a cosine-based test result.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.
-
Constructor Details
-
CompareDistance
private CompareDistance()No instantiation.
-
-
Method Details
-
triageCos
Returns a cosine-based test result. This is the fastest test, it handle all angles, but has a wide margin of uncertainty. -
triageSin2
Returns a sine-based test result, which has very good accuracy for small angles, although it only handles angles below 90 degrees. -
triage
Returns a test result based on firsttriageCos(com.google.common.geometry.S2Point, com.google.common.geometry.S2Point, double)
and thentriageSin2(com.google.common.geometry.S2Point, com.google.common.geometry.S2Point, double)
, so it is fast for any input where exact arithmetic isn't needed. -
exact
Callsexact(BigPoint, BigPoint, BigDecimal)
with its more precise types. -
exact
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.
-