func (l loopRegion) intersects(loop *s2.Loop) bool { // Quick check if the bounding boxes intersect if !l.RectBound().Intersects(loop.RectBound()) { return false } // Quick check to see if the first vertex is in the loop. if l.ContainsPoint(loop.Vertex(0)) { return true } // At this stage the one vertex is outside the loop. We check if any of the edges of the cell // cross the loop. if l.edgesCrossPoints(loop.Vertices()) { return true } // At this stage we know that there is one point of the loop is outside us and the boundaries do // not interesect. The only way for the loops to intersect is if it contains us. We test this // by checking if an arbitrary vertex is inside the loop. if loop.RectBound().Contains(l.RectBound()) { return loop.ContainsPoint(l.Vertex(0)) } return false }