Package com.google.common.geometry
Class S2EdgeUtil.EdgeCrosser
- java.lang.Object
-
- com.google.common.geometry.S2EdgeUtil.EdgeCrosser
-
- Enclosing class:
- S2EdgeUtil
public static final class S2EdgeUtil.EdgeCrosser extends Object
Used to efficiently test a fixed edge AB against an edge chain. To use it,initializewith the edge AB, and callrobustCrossing(S2Point, S2Point)oredgeOrVertexCrossing(S2Point, S2Point)with each edge of the chain.This class is not thread-safe.
-
-
Constructor Summary
Constructors Constructor Description EdgeCrosser()Constructs an uninitialized edge crosser.EdgeCrosser(S2Point a, S2Point b)Convenience constructor that calls init() with the given fixed edge AB.EdgeCrosser(S2Point a, S2Point b, S2Point c)AB is the given fixed edge, and C is the first vertex of the vertex chain.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanedgeOrVertexCrossing(S2Point d)This method is equivalent to theedgeOrVertexCrossing(com.google.common.geometry.S2Point)method defined below.booleanedgeOrVertexCrossing(S2Point c, S2Point d)AsedgeOrVertexCrossing(S2Point), but restarts atcif that is not the previous endpoint.voidinit(S2Point a, S2Point b)voidrestartAt(S2Point c)Call this method when your chain 'jumps' to a new place.introbustCrossing(S2Point d)This method is equivalent to calling therobustCrossing(com.google.common.geometry.S2Point)function (defined below) on the edges AB and CD.introbustCrossing(S2Point c, S2Point d)AsrobustCrossing(S2Point), but restarts atcif that is not the previous endpoint.
-
-
-
Constructor Detail
-
EdgeCrosser
public EdgeCrosser()
Constructs an uninitialized edge crosser. Invokeinit(S2Point, S2Point)before calling the other methods.
-
EdgeCrosser
public EdgeCrosser(S2Point a, S2Point b)
Convenience constructor that calls init() with the given fixed edge AB.
-
-
Method Detail
-
restartAt
public void restartAt(S2Point c)
Call this method when your chain 'jumps' to a new place.
-
robustCrossing
public int robustCrossing(S2Point d)
This method is equivalent to calling therobustCrossing(com.google.common.geometry.S2Point)function (defined below) on the edges AB and CD. It returns +1 if there is a crossing, -1 if there is no crossing, and 0 if two points from different edges are the same. Returns 0 or -1 if either edge is degenerate. As a side effect, it saves vertex D to be used as the next vertex C.
-
robustCrossing
public int robustCrossing(S2Point c, S2Point d)
AsrobustCrossing(S2Point), but restarts atcif that is not the previous endpoint.
-
edgeOrVertexCrossing
public boolean edgeOrVertexCrossing(S2Point d)
This method is equivalent to theedgeOrVertexCrossing(com.google.common.geometry.S2Point)method defined below. It is similar torobustCrossing(com.google.common.geometry.S2Point), but handles cases where two vertices are identical in a way that makes it easy to implement point-in-polygon containment tests.
-
edgeOrVertexCrossing
public boolean edgeOrVertexCrossing(S2Point c, S2Point d)
AsedgeOrVertexCrossing(S2Point), but restarts atcif that is not the previous endpoint.
-
-