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

Method iteratorContainsPoint

s2/loop.go:720–738  ·  view source on GitHub ↗

iteratorContainsPoint reports if the iterator that is positioned at the ShapeIndexCell that may contain p, contains the point p.

(it *ShapeIndexIterator, p Point)

Source from the content-addressed store, hash-verified

718// iteratorContainsPoint reports if the iterator that is positioned at the ShapeIndexCell
719// that may contain p, contains the point p.
720func (l *Loop) iteratorContainsPoint(it *ShapeIndexIterator, p Point) bool {
721 // Test containment by drawing a line segment from the cell center to the
722 // given point and counting edge crossings.
723 aClipped := it.IndexCell().findByShapeID(0)
724 inside := aClipped.containsCenter
725 if len(aClipped.edges) > 0 {
726 center := it.Center()
727 crosser := NewEdgeCrosser(center, p)
728 aiPrev := -2
729 for _, ai := range aClipped.edges {
730 if ai != aiPrev+1 {
731 crosser.RestartAt(l.Vertex(ai))
732 }
733 aiPrev = ai
734 inside = inside != crosser.EdgeOrVertexChainCrossing(l.Vertex(ai+1))
735 }
736 }
737 return inside
738}
739
740// RegularLoop creates a loop with the given number of vertices, all
741// located on a circle of the specified radius around the given center.

Callers 3

ContainsPointMethod · 0.95
ContainsCellMethod · 0.95
IntersectsCellMethod · 0.95

Calls 7

RestartAtMethod · 0.95
VertexMethod · 0.95
NewEdgeCrosserFunction · 0.85
findByShapeIDMethod · 0.80
IndexCellMethod · 0.80
CenterMethod · 0.45

Tested by

no test coverage detected