// Intersects reports whether this rectangle and the other rectangle have any points in common.
195917
func (r Rect) Intersects(other Rect) bool {
	return r.X.Intersects(other.X) && r.Y.Intersects(other.Y)
}
819211
func (set WordSet) Intersect(other WordSet) WordSet {
	intersection := NewWordSet()
	// loop over smaller set
	if set.Cardinality() < other.Cardinality() {
		for elem := range set {
			if other.Contains(elem) {
				intersection.Add(elem)
			}
		}
	} else {
		for elem := range other {
			if set.Contains(elem) {
				intersection.Add(elem)
			}
		}
	}
	return intersection
}
924570
func intersect(as, bs [][]byte) [][]byte {
	i := make([][]byte, 0, cmn.MinInt(len(as), len(bs)))
	for _, a := range as {
		for _, b := range bs {
			if bytes.Equal(a, b) {
				i = append(i, a)
			}
		}
	}
	return i
}
902960
func (s1 StringSet) Intersect(s2 StringSet) StringSet {
	return setOperation(s1, s2, true)
}
377048
func (r Region) Intersects(other Region) bool {
	return r == other || r.Intersection(other).Size() > 0
}
624723
func intersect(si *topo.ShardInfo, allShards []*topo.ShardInfo) bool {
	for _, shard := range allShards {
		if key.KeyRangesIntersect(si.KeyRange, shard.KeyRange) {
			return true
		}
	}
	return false
}
191343
func (r Rect) Intersection(other Rect) Rect {
	xx := r.X.Intersection(other.X)
	yy := r.Y.Intersection(other.Y)
	if xx.IsEmpty() || yy.IsEmpty() {
		return EmptyRect()
	}

	return Rect{xx, yy}
}
714782
func (members Members) Intersect(otherMembers Members) Members {
	var res Members
	m := otherMembers.ByID()
	for _, member := range members {
		if _, exists := m[string(member.PKIid)]; exists {
			res = append(res, member)
		}
	}
	return res
}
74315
func (s *SyncedSet) Intersect(other *SyncedSet) *SyncedSet {
	newSet := NewSyncedSet()
	for k := range s.set {
		if other.Contains(k) {
			newSet.Add(k)
		}
	}
	return &newSet
}
1070955
func (p *Path) Intersects(geometry interface{}) bool {
	var result bool

	switch g := geometry.(type) {
	case Line:
		result = p.IntersectsLine(&g)
	case *Line:
		result = p.IntersectsLine(g)
	case Path:
		result = p.IntersectsPath(&g)
	case *Path:
		result = p.IntersectsPath(g)
	default:
		panic("can only determine intersection with lines and paths")
	}

	return result
}
456531
func (s *Set) Intersection(other *Set) *Set {
	result := new(Set)
	if s == nil {
		return result
	}
	if other != nil {
		for _, v := range s.m {
			if other.Include(v) {
				result.Add(v)
			}
		}
	}

	return result
}
452099
func (i Interval) Intersects(oi Interval) bool {
	if i.IsEmpty() || oi.IsEmpty() {
		return false
	}
	if i.IsInverted() {
		return oi.IsInverted() || oi.Lo <= i.Hi || oi.Hi >= i.Lo
	}
	if oi.IsInverted() {
		return oi.Lo <= i.Hi || oi.Hi >= i.Lo
	}
	return oi.Lo <= i.Hi && oi.Hi >= i.Lo
}
912253
func (set StringSet) Intersect(other StringSet) StringSet {
	intersection := NewStringSet()
	// loop over smaller set
	if set.Cardinality() < other.Cardinality() {
		for elem := range set {
			if other.Contains(elem) {
				intersection.Add(elem)
			}
		}
	} else {
		for elem := range other {
			if set.Contains(elem) {
				intersection.Add(elem)
			}
		}
	}
	return intersection
}
267361
func (l *Loop) Intersects(o *Loop) bool {
	// Given two loops, A and B, A.Intersects(B) if and only if !A.Complement().Contains(B).
	//
	// This code is similar to Contains, but is optimized for the case
	// where both loops enclose less than half of the sphere.
	if !l.bound.Intersects(o.bound) {
		return false
	}

	// Check whether there are any edge crossings, and also check the loop
	// relationship at any shared vertices.
	relation := &intersectsRelation{}
	if hasCrossingRelation(l, o, relation) {
		return true
	}
	if relation.foundSharedVertex {
		return false
	}

	// Since there are no edge intersections or shared vertices, the loops
	// intersect only if A contains B, B contains A, or the two loops contain
	// each other's boundaries.  These checks are usually cheap because of the
	// bounding box preconditions.  Note that neither loop is empty (because of
	// the bounding box check above), so it is safe to access vertex(0).

	// Check whether A contains B, or A and B contain each other's boundaries.
	// (Note that A contains all the vertices of B in either case.)
	if l.subregionBound.Contains(o.bound) || l.bound.Union(o.bound).IsFull() {
		if l.ContainsPoint(o.Vertex(0)) {
			return true
		}
	}
	// Check whether B contains A.
	if o.subregionBound.Contains(l.bound) {
		if o.ContainsPoint(l.Vertex(0)) {
			return true
		}
	}
	return false
}
1049146
func (l Line) IntersectCircle(c Circle) Vec {
	// Get the point on the line closest to the center of the circle.
	closest := l.Closest(c.Center)
	cirToClosest := c.Center.To(closest)

	if cirToClosest.Len() >= c.Radius {
		return ZV
	}

	return cirToClosest.Scaled(cirToClosest.Len() - c.Radius)
}
935931
func (l Line) IntersectRect(r Rect) Vec {
	// Check if either end of the line segment are within the rectangle
	if r.Contains(l.A) || r.Contains(l.B) {
		// Use the Rect.Intersect to get minimal return value
		rIntersect := l.Bounds().Intersect(r)
		if rIntersect.H() > rIntersect.W() {
			// Go vertical
			return V(0, rIntersect.H())
		}
		return V(rIntersect.W(), 0)
	}

	// Check if any of the rectangles' edges intersect with this line.
	for _, edge := range r.Edges() {
		if _, ok := l.Intersect(edge); ok {
			// Get the closest points on the line to each corner, where:
			//  - the point is contained by the rectangle
			//  - the point is not the corner itself
			corners := r.Vertices()
			closest := ZV
			closestCorner := corners[0]
			for _, c := range corners {
				cc := l.Closest(c)
				if closest == ZV || (closest.Len() > cc.Len() && r.Contains(cc)) {
					closest = cc
					closestCorner = c
				}
			}

			return closest.To(closestCorner)
		}
	}

	// No intersect
	return ZV
}
1285404
func (c Cap) Intersects(other Cap) bool {
	if c.IsEmpty() || other.IsEmpty() {
		return false
	}

	return c.radius.Add(other.radius) >= ChordAngleBetweenPoints(c.center, other.center)
}