MCPcopy
hub / github.com/golang/geo / Crossings

Method Crossings

s2/crossing_edge_query.go:55–78  ·  view source on GitHub ↗

Crossings returns the set of edge of the shape S that intersect the given edge AB. If the CrossingType is Interior, then only intersections at a point interior to both edges are reported, while if it is CrossingTypeAll then edges that share a vertex are also reported.

(a, b Point, shape Shape, crossType CrossingType)

Source from the content-addressed store, hash-verified

53// edges are reported, while if it is CrossingTypeAll then edges that share a vertex
54// are also reported.
55func (c *CrossingEdgeQuery) Crossings(a, b Point, shape Shape, crossType CrossingType) []int {
56 edges := c.candidates(a, b, shape)
57 if len(edges) == 0 {
58 return nil
59 }
60
61 crosser := NewEdgeCrosser(a, b)
62 out := 0
63 n := len(edges)
64
65 for in := range n {
66 b := shape.Edge(edges[in])
67 sign := crosser.CrossingSign(b.V0, b.V1)
68 if crossType == CrossingTypeAll && (sign == MaybeCross || sign == Cross) || crossType != CrossingTypeAll && sign == Cross {
69 edges[out] = edges[in]
70 out++
71 }
72 }
73
74 if out < n {
75 edges = edges[0:out]
76 }
77 return edges
78}
79
80// EdgeMap stores a sorted set of edge ids for each shape.
81type EdgeMap map[Shape][]int

Callers 1

Calls 4

candidatesMethod · 0.95
CrossingSignMethod · 0.95
NewEdgeCrosserFunction · 0.85
EdgeMethod · 0.65

Tested by 1