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

Method IsNormalized

s2/loop.go:860–872  ·  view source on GitHub ↗

IsNormalized reports whether the loop area is at most 2*pi. Degenerate loops are handled consistently with Sign, i.e., if a loop can be expressed as the union of degenerate or nearly-degenerate CCW triangles, then it will always be considered normalized.

()

Source from the content-addressed store, hash-verified

858// expressed as the union of degenerate or nearly-degenerate CCW triangles,
859// then it will always be considered normalized.
860func (l *Loop) IsNormalized() bool {
861 // Optimization: if the longitude span is less than 180 degrees, then the
862 // loop covers less than half the sphere and is therefore normalized.
863 if l.bound.Lng.Length() < math.Pi {
864 return true
865 }
866
867 // We allow some error so that hemispheres are always considered normalized.
868 // TODO(roberts): This is no longer required by the Polygon implementation,
869 // so alternatively we could create the invariant that a loop is normalized
870 // if and only if its complement is not normalized.
871 return l.TurningAngle() >= -l.turningAngleMaxError()
872}
873
874// Normalize inverts the loop if necessary so that the area enclosed by the loop
875// is at most 2*pi.

Callers 6

NormalizeMethod · 0.95
AreaMethod · 0.95

Calls 3

TurningAngleMethod · 0.95
turningAngleMaxErrorMethod · 0.95
LengthMethod · 0.45