Finds an intersection box that is common to both given boxes.

        :param box1: Box object 1
        :param box2: Box object 2
        :return: None if there is no intersection otherwise the new Box
779723
def intersection_box(box1, box2):
        
        b1_x2, b1_y2 = box1.bottom_right()
        b2_x2, b2_y2 = box2.bottom_right()

        x, y = max(box1.x, box2.x), max(box1.y, box2.y)
        x2, y2 = min(b1_x2, b2_x2), min(b1_y2, b2_y2)
        w, h = max(0, x2-x), max(0, y2-y)
        return Box(x, y, w, h)
1328981
def is_bbox_not_intersecting(self, other):
        """"""

        self_x_min, self_x_max, self_y_min, self_y_max = self.get_bbox()
        other_x_min, other_x_max, other_y_min, other_y_max = other.get_bbox()

        return \
            self_x_min > other_x_max or \
            other_x_min > self_x_max or \
            self_y_min > other_y_max or \
            other_y_min > self_y_max
48652
def intersection(self, other):
        
        startopen = other.startopen if self.start is None \
            else self.startopen if other.start is None \
            else other.startopen if self.start < other.start \
            else self.startopen if self.start > other.start \
            else (self.startopen or other.startopen)
        endopen = other.endopen if self.end is None \
            else self.endopen if other.end is None \
            else other.endopen if self.end > other.end \
            else self.endopen if self.end < other.end \
            else (self.endopen or other.endopen)

        new_start = self.start if other.start is None \
            else other.start if self.start is None \
            else max(self.start, other.start)
        new_end = self.end if other.end is None \
            else other.end if self.end is None \
            else min(self.end, other.end)

        interval = INTERVAL_LOOKUP[(startopen, endopen)]

        return DateRange(new_start, new_end, interval)
978527
def intersection(self,other):
        ""
        res = {}
        if set(self.sets.keys()) != set(other.sets.keys()):
            raise KeyError('Incompatible patches in intersection')
        for name,s1 in self.sets.items():
            s2 = other.sets[name]
            res[name] = s1.intersection(s2)
        return Patch(res)
10162
def intersect(a, b):
    
    if a[x0] == a[x1] or a[y0] == a[y1]:
        return False
    if b[x0] == b[x1] or b[y0] == b[y1]:
        return False
    return a[x0] <= b[x1] and b[x0] <= a[x1] and a[y0] <= b[y1] and b[y0] <= a[y1]
757515
protected boolean intersect(GVRSceneObject.BoundingVolume bv1, GVRSceneObject.BoundingVolume bv2)
    {
        return  (bv1.maxCorner.x >= bv2.minCorner.x) &&
                (bv1.maxCorner.y >= bv2.minCorner.y) &&
                (bv1.maxCorner.z >= bv2.minCorner.z) &&
                (bv1.minCorner.x <= bv2.maxCorner.x) &&
                (bv1.minCorner.y <= bv2.maxCorner.y) &&
                (bv1.minCorner.z <= bv2.maxCorner.z);
    }
94002
def iou(box1, box2):
        
        int_box = Box.intersection_box(box1, box2)
        int_area = int_box.area()
        union_area = box1.area() + box2.area() - int_area

        result = 0.0
        if union_area > 0:
            result = float(int_area) / float(union_area)

        return result
194706
def boxes_intersect(box1, box2):
    """"""
    xmin1, xmax1, ymin1, ymax1 = box1
    xmin2, xmax2, ymin2, ymax2 = box2
    if interval_intersection_width(xmin1, xmax1, xmin2, xmax2) and \
            interval_intersection_width(ymin1, ymax1, ymin2, ymax2):
        return True
    else:
        return False
571851
def intersection(self, other, ignore_conflicts=False):
        """"""
        result = self.copy()
        result.intersection_update(other, ignore_conflicts)
        return result
611732
def _comp_bbox(el, el2):
    
    # only compare if both elements have x/y coordinates
    if _comp_bbox_keys_required <= set(el.keys()) and \
            _comp_bbox_keys_required <= set(el2.keys()):
        if _box_in_box(el2, el):
            return 1
        if _box_in_box(el, el2):
            return -1
    return 0
955462
def intersect(self,range2):
    
    if not self.overlaps(range2): return None
    return type(self)(self.chr,max(self.start,range2.start)+self._start_offset,min(self.end,range2.end),self.payload,self.dir)
920230
private static <T> List<T> intersect(T[] first, T[] second) {
    List<T> result = new ArrayList<>();
    for (T a : first) {
      for (T b : second) {
        if (a.equals(b)) {
          result.add(b);
          break;
        }
      }
    }
    return result;
  }
84759
public static double overlap(SpatialComparable box1, SpatialComparable box2) {
    final int dim = assertSameDimensionality(box1, box2);

    // the maximal and minimal value of the overlap box.
    double omax, omin;

    // the overlap volume
    double overlap = 1.;

    for(int i = 0; i < dim; i++) {
      // The maximal value of that overlap box in the current
      // dimension is the minimum of the max values.
      omax = Math.min(box1.getMax(i), box2.getMax(i));
      // The minimal value is the maximum of the min values.
      omin = Math.max(box1.getMin(i), box2.getMin(i));

      // if omax <= omin in any dimension, the overlap box has a volume of zero
      if(omax <= omin) {
        return 0.;
      }

      overlap *= omax - omin;
    }

    return overlap;
  }
273632
def overlap(r1: 'Rectangle', r2: 'Rectangle'):
        
        h_overlaps = (r1.left <= r2.right) and (r1.right >= r2.left)
        v_overlaps = (r1.bottom >= r2.top) and (r1.top <= r2.bottom)
        return h_overlaps and v_overlaps
635955
public static boolean intersects(final RoaringBitmap x1, final RoaringBitmap x2) {
    final int length1 = x1.highLowContainer.size(), length2 = x2.highLowContainer.size();
    int pos1 = 0, pos2 = 0;

    while (pos1 < length1 && pos2 < length2) {
      final short s1 = x1.highLowContainer.getKeyAtIndex(pos1);
      final short s2 = x2.highLowContainer.getKeyAtIndex(pos2);
      if (s1 == s2) {
        final Container c1 = x1.highLowContainer.getContainerAtIndex(pos1);
        final Container c2 = x2.highLowContainer.getContainerAtIndex(pos2);
        if (c1.intersects(c2)) {
          return true;
        }
        ++pos1;
        ++pos2;
      } else if (Util.compareUnsigned(s1, s2) < 0) { // s1 < s2
        pos1 = x1.highLowContainer.advanceUntil(s2, pos1);
      } else { // s1 > s2
        pos2 = x2.highLowContainer.advanceUntil(s1, pos2);
      }
    }
    return false;
  }
313225
def _intersection(d1,d2):
    '''
        
    '''
    i = {}
    ds = _diff_internal(d1,d2)
    for key in ds['same']:
        i[key] = d1[key]
    return(i)
1283023
def do_bb_intersect(a, b):
    """"""
    return a.p1.x <= b.p2.x \
        and a.p2.x >= b.p1.x \
        and a.p1.y <= b.p2.y \
        and a.p2.y >= b.p1.y