Package com.google.common.geometry
Class S2Predicates.CompareDistance
- java.lang.Object
-
- com.google.common.geometry.S2Predicates.CompareDistance
-
- Enclosing class:
- S2Predicates
static class S2Predicates.CompareDistance extends java.lang.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 Summary
Constructors Modifier Constructor Description private
CompareDistance()
No instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
exact(BigPoint x, BigPoint y, java.math.BigDecimal r2)
Returns a BigDecimal-based test result, which is exact for all inputs but very slow.static int
exact(S2Point x, S2Point y, double r2)
Callsexact(BigPoint, BigPoint, BigDecimal)
with its more precise types.static int
triage(S2Point x, S2Point y, double r2)
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
triageCos(S2Point x, S2Point y, double r2)
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.
-
-
-
Method Detail
-
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 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
public static int exact(S2Point x, S2Point y, double r2)
Callsexact(BigPoint, BigPoint, BigDecimal)
with its more precise types.
-
exact
public static int exact(BigPoint x, BigPoint y, java.math.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.
-
-