Example #1
0
// Intersects returns true if the two loops intersect.
func Intersects(l1 *s2.Loop, l2 *s2.Loop) bool {
	if l2.NumEdges() > l1.NumEdges() {
		// Use the larger loop for edge indexing.
		return loopRegion{l2}.intersects(l1)
	}
	return loopRegion{l1}.intersects(l2)
}
Example #2
0
func loopArea(l *s2.Loop) float64 {
	n := l.NumEdges()
	origin := l.Vertex(0)
	var area float64
	for i := 1; i < n-1; i++ {
		area += s2.PointArea(origin, l.Vertex(i), l.Vertex(i+1)) * float64(s2.RobustSign(origin, l.Vertex(i), l.Vertex(i+1)))
	}
	return area
}