Skip to content

Commit

Permalink
s2.Loop: IntersectsCell now returns true if the first point of the lo…
Browse files Browse the repository at this point in the history
…op is contained by cell
  • Loading branch information
azr committed Nov 15, 2016
1 parent ad39d1b commit 67a6d66
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion s2/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,12 @@ func (l Loop) ContainsCell(c Cell) bool {
return true
}

// IntersectsCell checks if any edge of the cell intersects the loop or if the cell is contained.
// IntersectsCell checks if any edge of the cell intersects the loop, if the loop is contained or if the cell is contained.
// Does not count for loop interior and uses raycasting.
func (l Loop) IntersectsCell(c Cell) bool {
if c.ContainsPoint(l.Vertices[0]) {
return true
}
for i := 0; i < 4; i++ {
crosser := NewChainEdgeCrosser(c.Vertex(i), c.Vertex((i+1)%4), l.Vertex(0))
for _, v := range l.Vertices[1:] {
Expand Down

0 comments on commit 67a6d66

Please sign in to comment.