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

Method ContainsNested

s2/loop.go:956–980  ·  view source on GitHub ↗

ContainsNested reports whether the given loops is contained within this loop. This function does not test for edge intersections. The two loops must meet all of the Polygon requirements; for example this implies that their boundaries may not cross or have any shared edges (although they may have sha

(other *Loop)

Source from the content-addressed store, hash-verified

954// boundaries may not cross or have any shared edges (although they may have
955// shared vertices).
956func (l *Loop) ContainsNested(other *Loop) bool {
957 if !l.subregionBound.Contains(other.bound) {
958 return false
959 }
960
961 // Special cases to handle either loop being empty or full. Also bail out
962 // when B has no vertices to avoid heap overflow on the vertex(1) call
963 // below. (This method is called during polygon initialization before the
964 // client has an opportunity to call IsValid().)
965 if l.isEmptyOrFull() || other.NumVertices() < 2 {
966 return l.IsFull() || other.IsEmpty()
967 }
968
969 // We are given that A and B do not share any edges, and that either one
970 // loop contains the other or they do not intersect.
971 m, ok := l.findVertex(other.Vertex(1))
972 if !ok {
973 // Since other.vertex(1) is not shared, we can check whether A contains it.
974 return l.ContainsPoint(other.Vertex(1))
975 }
976
977 // Check whether the edge order around other.Vertex(1) is compatible with
978 // A containing B.
979 return WedgeContains(l.Vertex(m-1), l.Vertex(m), l.Vertex(m+1), other.Vertex(0), other.Vertex(2))
980}
981
982// surfaceIntegralFloat64 computes the oriented surface integral of some quantity f(x)
983// over the loop interior, given a function f(A,B,C) that returns the

Callers 2

insertLoopMethod · 0.80
TestLoopRelationsFunction · 0.80

Calls 9

isEmptyOrFullMethod · 0.95
IsFullMethod · 0.95
findVertexMethod · 0.95
VertexMethod · 0.95
ContainsPointMethod · 0.95
WedgeContainsFunction · 0.85
NumVerticesMethod · 0.80
IsEmptyMethod · 0.65
ContainsMethod · 0.45

Tested by 1

TestLoopRelationsFunction · 0.64