Compute the intersection of two sorted integer lists.

@param px First list
@param py Second list
@return Intersection size.
965308
private int intersectionSize(int[] px, int[] py) {
    int i = 0, j = 0, c = 0;
    while(i < px.length && j < py.length) {
      final int vx = px[i], vy = py[j];
      if(vx < vy) {
        ++i;
      }
      else if(vx > vy) {
        ++j;
      }
      else {
        ++c;
        ++i;
        ++j;
      }
    }
    return c;
  }
1374401
public double overlapAbsolute(DoubleRange other) {
    if (!intersects(other)) {
      return 0;
    }
    int loCmp = lo.compareTo(other.lo);
    int hiCmp = hi.compareTo(other.hi);
    if (loCmp >= 0 && hiCmp <= 0) {
      return this.length();
    } else if (loCmp <= 0 && hiCmp >= 0) {
      return other.length();
    } else {
      double newLo = (loCmp >= 0) ? this.lo : other.lo;
      double newHi = (hiCmp <= 0) ? this.hi : other.hi;
      return newHi - newLo;
    }
  }
260982
public BBox calculateIntersection(BBox bBox) {
        if (!this.intersects(bBox))
            return null;

        double minLon = Math.max(this.minLon, bBox.minLon);
        double maxLon = Math.min(this.maxLon, bBox.maxLon);
        double minLat = Math.max(this.minLat, bBox.minLat);
        double maxLat = Math.min(this.maxLat, bBox.maxLat);

        return new BBox(minLon, maxLon, minLat, maxLat);
    }
566030
public static long getRotatedX(final long pX, final long pY,
                                   final long pCenterX, final long pCenterY,
                                   final double pCos, final double pSin) {
        return pCenterX + Math.round((pX - pCenterX) * pCos - (pY - pCenterY) * pSin);
    }
105370
public boolean isInClipArea(final long pX, final long pY) {
        return pX > mXMin && pX < mXMax && pY > mYMin && pY < mYMax;
    }
571469
public static <T> List<T> intersection(List<T> arr1, int start1, int end1, List<T> arr2,
                                           int start2, int end2) {
        if (start1 > end1 || start2 > end2) {
            throw new IllegalArgumentException("起始位置必须小于等于结束位置");
        }
        if (start1 == end1 || start2 == end2) {
            return Collections.emptyList();
        }

        List<T> list = new ArrayList<>();
        for (int i = start1; i < end1; i++) {
            int index = arr2.indexOf(arr1.get(i));
            if (index < end2 && index >= start2) {
                list.add(arr1.get(i));
            }
        }
        return list;
    }
895826
public static boolean intersect(long[] x, long[] y) {
    final int min = (x.length < y.length) ? x.length : y.length;
    for(int i = 0; i < min; i++) {
      if((x[i] & y[i]) != 0L) {
        return true;
      }
    }
    return false;
  }
124071
public double intersectX(double x)
	{
		if (direction.x == 0)
			return Double.NaN;
		return (x - origin.x) / direction.x;
	}
434116
public static int intersectCubic (float x1, float y1, float cx1, float cy1,
                                      float cx2, float cy2, float x2, float y2,
                                      float rx1, float ry1, float rx2, float ry2) {
        // LEFT/RIGHT/UP
        if ((rx2 < x1 && rx2 < cx1 && rx2 < cx2 && rx2 < x2)
                || (rx1 > x1 && rx1 > cx1 && rx1 > cx2 && rx1 > x2)
                || (ry1 > y1 && ry1 > cy1 && ry1 > cy2 && ry1 > y2)) {
            return 0;
        }

        // DOWN
        if (ry2 < y1 && ry2 < cy1 && ry2 < cy2 && ry2 < y2 && rx1 != x1 && rx1 != x2) {
            if (x1 < x2) {
                return x1 < rx1 && rx1 < x2 ? 1 : 0;
            }
            return x2 < rx1 && rx1 < x1 ? -1 : 0;
        }

        // INSIDE
        CubicCurveH c = new CubicCurveH(x1, y1, cx1, cy1, cx2, cy2, x2, y2);
        float px1 = rx1 - x1;
        float py1 = ry1 - y1;
        float px2 = rx2 - x1;
        float py2 = ry2 - y1;

        float[] res1 = new float[3];
        float[] res2 = new float[3];
        int rc1 = c.solvePoint(res1, px1);
        int rc2 = c.solvePoint(res2, px2);

        // LEFT/RIGHT
        if (rc1 == 0 && rc2 == 0) {
            return 0;
        }

        float minX = px1 - DELTA;
        float maxX = px2 + DELTA;

        // Build bound --------------------------------------------------------
        float[] bound = new float[40];
        int bc = 0;
        // Add roots
        bc = c.addBound(bound, bc, res1, rc1, minX, maxX, false, 0);
        bc = c.addBound(bound, bc, res2, rc2, minX, maxX, false, 1);
        // Add extremal points
        rc2 = c.solveExtremeX(res2);
        bc = c.addBound(bound, bc, res2, rc2, minX, maxX, true, 2);
        rc2 = c.solveExtremeY(res2);
        bc = c.addBound(bound, bc, res2, rc2, minX, maxX, true, 4);
        // Add start and end
        if (rx1 < x1 && x1 < rx2) {
            bound[bc++] = 0f;
            bound[bc++] = 0f;
            bound[bc++] = 0f;
            bound[bc++] = 6;
        }
        if (rx1 < x2 && x2 < rx2) {
            bound[bc++] = 1f;
            bound[bc++] = c.ax;
            bound[bc++] = c.ay;
            bound[bc++] = 7;
        }
        // End build bound ----------------------------------------------------

        int cross = crossBound(bound, bc, py1, py2);
        if (cross != UNKNOWN) {
            return cross;
        }
        return c.cross(res1, rc1, py1, py2);
    }
807904
def intersection(*argv):
        
        res = OrderedSet(argv[0])
        for ods in argv:
            res = ods & res
        return res
1009556
private boolean intersection(
            final long pX0, final long pY0, final long pX1, final long pY1,
            final long pX2, final long pY2, final long pX3, final long pY3
    ) {
        return SegmentIntersection.intersection(
                pX0, pY0, pX1, pY1,
                pX2, pY2, pX3, pY3, mOptimIntersection);
    }
213897
private static boolean check(
            final double pXA, final double pYA, final double pXB, final double pYB,
            final double pXC, final double pYC, final double pXD, final double pYD,
            final PointL pIntersection,
            final double pXI, final double pYI
    ) {
        if (pXI < Math.min(pXA, pXB) || pXI > Math.max(pXA, pXB)) {
            return false;
        }
        if (pXI < Math.min(pXC, pXD) || pXI > Math.max(pXC, pXD)) {
            return false;
        }
        if (pYI < Math.min(pYA, pYB) || pYI > Math.max(pYA, pYB)) {
            return false;
        }
        if (pYI < Math.min(pYC, pYD) || pYI > Math.max(pYC, pYD)) {
            return false;
        }
        if (pIntersection != null) {
            pIntersection.x = Math.round(pXI);
            pIntersection.y = Math.round(pYI);
        }
        return true;
    }
277391
public int[] PixelsToTile( int px, int py ) {
        int tx = (int) Math.ceil(px / ((double) tileSize) - 1);
        int ty = (int) Math.ceil(py / ((double) tileSize) - 1);
        return new int[]{tx, ty};
    }
498284
public static long intersectionCount(OpenBitSet a, OpenBitSet b) {
        return BitUtil.pop_intersect( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) );
    }
203751
public static Bbox intersection(Bbox one, Bbox two) {
		if (!intersects(one, two)) {
			return null;
		} else {
			double minx = two.getX() > one.getX() ? two.getX() : one.getX();
			double maxx = two.getMaxX() < one.getMaxX() ? two.getMaxX() : one.getMaxX();
			double miny = two.getY() > one.getY() ? two.getY() : one.getY();
			double maxy = two.getMaxY() < one.getMaxY() ? two.getMaxY() : one.getMaxY();
			return new Bbox(minx, miny, (maxx - minx), (maxy - miny));
		}
	}
1175155
public static double[] intersection(double[] kb1, double[] kb2) {
    double[] interp = new double[2];
    if (kb1[0] == 1) {
      interp[0] = kb1[1];
      interp[1] = kb2[1] * interp[0] + kb2[2];
    } else if (kb2[0] == 1) {
      interp[0] = kb2[1];
      interp[1] = kb1[1] * interp[0] + kb1[2];
    } else {
      interp[0] = (kb2[2] - kb1[2]) / (kb1[1] - kb2[1]);
      interp[1] = kb1[1] * interp[0] + kb1[2];
    }
    return interp;

  }
227502
def get_intersection(bbox1, bbox2):
    
    intersection = []
    page_1, page_width, page_height, top_1, left_1, bottom_1, right_1 = bbox1
    page_2, _, _, top_2, left_2, bottom_2, right_2 = bbox2
    if page_1 == page_2:
        if doOverlap(
            (top_1, left_1, bottom_1, right_1), (top_2, left_2, bottom_2, right_2)
        ):
            intersection += [
                (
                    page_1,
                    page_width,
                    page_height,
                    max(top_1, top_2),
                    max(left_1, left_2),
                    min(bottom_1, bottom_2),
                    min(right_1, right_2),
                )
            ]
    return intersection