return the quantity of intersect points
549629
private void intersectShape (List<Edge> edges, double[] coords1, int length1,
                                 double[] coords2, int length2, Edge initEdge) {
        int areaOfEdge1, areaOfEdge2;
        int initBegin, initEnd;
        int addBegin, addEnd;
        double x1, y1, x2, y2, x3, y3, x4, y4;
        double[] point = new double[2];
        Edge edge;

        if (initEdge.areaNumber == 0) {
            x1 = coords1[2 * initEdge.begIndex];
            y1 = coords1[2 * initEdge.begIndex + 1];
            x2 = coords1[2 * initEdge.endIndex];
            y2 = coords1[2 * initEdge.endIndex + 1];
            areaOfEdge1 = 0;
        } else {
            x1 = coords2[2 * initEdge.begIndex];
            y1 = coords2[2 * initEdge.begIndex + 1];
            x2 = coords2[2 * initEdge.endIndex];
            y2 = coords2[2 * initEdge.endIndex + 1];
            areaOfEdge1 = 1;
        }

        for (Iterator<Edge> iter = edges.iterator(); iter.hasNext();) {
            edge = iter.next();

            if (edge.areaNumber == 0) {
                x3 = coords1[2 * edge.begIndex];
                y3 = coords1[2 * edge.begIndex + 1];
                x4 = coords1[2 * edge.endIndex];
                y4 = coords1[2 * edge.endIndex + 1];
                areaOfEdge2 = 0;
            } else {
                x3 = coords2[2 * edge.begIndex];
                y3 = coords2[2 * edge.begIndex + 1];
                x4 = coords2[2 * edge.endIndex];
                y4 = coords2[2 * edge.endIndex + 1];
                areaOfEdge2 = 1;
            }

            if ((areaOfEdge1 != areaOfEdge2) &&
                (GeometryUtil.intersectLines(x1, y1, x2, y2, x3, y3, x4, y4, point) == 1) &&
                (!containsPoint(point))) {

                if (initEdge.areaNumber == 0) {
                    initBegin = initEdge.begIndex;
                    initEnd = initEdge.endIndex;
                    addBegin = edge.begIndex;
                    addEnd = edge.endIndex;
                } else {
                    initBegin = edge.begIndex;
                    initEnd = edge.endIndex;
                    addBegin = initEdge.begIndex;
                    addEnd = initEdge.endIndex;
                }

                if (((initEnd == length1 - 1) && (initBegin == 0 && initEnd > initBegin)) ||
                    (((initEnd != length1 - 1) || (initBegin != 0)) &&
                     ((initBegin != length1 - 1) || (initEnd != 0)) && (initBegin > initEnd))) {
                    int temp = initBegin;
                    initBegin = initEnd;
                    initEnd = temp;
                }

                if (((addEnd == length2 - 1) && (addBegin == 0) && (addEnd > addBegin)) ||
                    (((addEnd != length2 - 1) || (addBegin != 0)) &&
                     ((addBegin != length2 - 1) || (addEnd != 0)) && (addBegin > addEnd))) {
                    int temp = addBegin;
                    addBegin = addEnd;
                    addEnd = temp;
                }

                IntersectPoint ip;
                for (Iterator<IntersectPoint> i = isectPoints.iterator(); i.hasNext();) {
                    ip = i.next();
                    if ((initBegin == ip.begIndex(true)) && (initEnd == ip.endIndex(true))) {
                        if (compare(ip.x(), ip.y(), point[0], point[1]) > 0) {
                            initEnd = -(isectPoints.indexOf(ip) + 1);
                            ip.setBegIndex1(-(isectPoints.size() + 1));
                        } else {
                            initBegin = -(isectPoints.indexOf(ip) + 1);
                            ip.setEndIndex1(-(isectPoints.size() + 1));
                        }
                    }

                    if ((addBegin == ip.begIndex(false)) && (addEnd == ip.endIndex(false))) {
                        if (compare(ip.x(), ip.y(), point[0], point[1]) > 0) {
                            addEnd = -(isectPoints.indexOf(ip) + 1);
                            ip.setBegIndex2(-(isectPoints.size() + 1));
                        } else {
                            addBegin = -(isectPoints.indexOf(ip) + 1);
                            ip.setEndIndex2(-(isectPoints.size() + 1));
                        }
                    }
                }

                isectPoints.add(new IntersectPoint(initBegin, initEnd, addBegin, addEnd,
                                                   point[0], point[1]));
            }
        }
    }
348010
function intersects (data, p1, q1, p2, q2) {
  return orient(data, p1, q1, p2) !== orient(data, p1, q1, q2) &&
    orient(data, p2, q2, p1) !== orient(data, p2, q2, q1)
}
449886
private void intersectionMatrix(int[][] res, ArrayList<int[]> partsx, ArrayList<int[]> partsy, int gridsize) {
    for(int x = 0; x < gridsize; x++) {
      final int[] px = partsx.get(x);
      final int[] rowx = res[x];
      for(int y = 0; y < gridsize; y++) {
        int[] py = partsy.get(y);
        rowx[y] = intersectionSize(px, py);
      }
    }
  }
648383
private static boolean intersectProp(int[] verts, int a, int b, int c, int d) {
        // Eliminate improper cases.
        if (collinear(verts, a, b, c) || collinear(verts, a, b, d) || collinear(verts, c, d, a)
                || collinear(verts, c, d, b))
            return false;

        return (left(verts, a, b, c) ^ left(verts, a, b, d)) && (left(verts, c, d, a) ^ left(verts, c, d, b));
    }
134131
def intersection(self, other):
        
        taxa1 = self.labels
        taxa2 = other.labels
        return taxa1 & taxa2
780567
def getPoints(self, pared=False):
        
        points = self._points[:]
        if pared:
            np = NodePare()
            np.addPoints(points)
            np.parePoints()
            points = np.getParedPoints()

        return points
1098849
def number_of_links(neighbors, datapoints, x, y)
      (0..datapoints.size-1).map do |i|
        neighbors.lookup(x,i) * neighbors.lookup(i,y)
      end.inject(0) {|m,v| m+v}
    end
1027190
private static Integer[] intersectedDocList(int[] facetDocList,
      Integer[] docSet) {
    if (facetDocList != null && docSet != null) {
      Integer[] c = new Integer[Math.min(facetDocList.length, docSet.length)];
      int ai = 0;
      int bi = 0;
      int ci = 0;
      while (ai < facetDocList.length && bi < docSet.length) {
        if (facetDocList[ai] < docSet[bi]) {
          ai++;
        } else if (facetDocList[ai] > docSet[bi]) {
          bi++;
        } else {
          if (ci == 0 || facetDocList[ai] != c[ci - 1]) {
            c[ci++] = facetDocList[ai];
          }
          ai++;
          bi++;
        }
      }
      return Arrays.copyOfRange(c, 0, ci);
    }
    return new Integer[] {};
  }
691648
def interval_intersection_width(a, b, c, d):
    """"""
    return max(0, min(b, d) - max(a, c))
1236533
public int getNumPoints() {
		if (isEmpty()) {
			return 0;
		}
		int total = exteriorRing.getNumPoints();
		if (interiorRings != null) {
			for (LinearRing interiorRing : interiorRings) {
				total += interiorRing.getNumPoints();
			}
		}
		return total;
	}
693067
static boolean intersect(int[] verts, int a, int b, int c, int d) {
        if (intersectProp(verts, a, b, c, d))
            return true;
        else if (between(verts, a, b, c) || between(verts, a, b, d) || between(verts, c, d, a)
                || between(verts, c, d, b))
            return true;
        else
            return false;
    }
195307
def calculate_overlap(self):
      """"""
      overs = []
      if not self.tx_obj1.range.overlaps(self.tx_obj2.range): return [] # if they dont overlap wont find anything
      for i in range(0,len(self.j1)):
        for j in range(0,len(self.j2)):
          if self.j1[i].overlaps(self.j2[j],tolerance=self.tolerance):
            overs.append([i,j])
      return overs
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
417184
def ranges_intersect(rset):
    
    if not rset:
        return None

    a = rset[0]
    for b in rset[1:]:
        if not a:
            return None
        a = range_intersect(a, b)

    return a
393067
def get_intersectionsbysubsets(df,cols_fracby2vals,cols_subset,col_ids):
    
    for col_fracby in cols_fracby2vals:
        val=cols_fracby2vals[col_fracby]
        ids=df.loc[(df[col_fracby]==val),col_ids].dropna().unique()
        for col_subset in cols_subset:
            for subset in dropna(df[col_subset].unique()):
                ids_subset=df.loc[(df[col_subset]==subset),col_ids].dropna().unique()
                df.loc[(df[col_subset]==subset),f'P {col_fracby} {col_subset}']=len(set(ids_subset).intersection(ids))/len(ids_subset)
    return df
1122511
function getIntersectionPoints(circles) {
        var ret = [];
        for (var i = 0; i < circles.length; ++i) {
            for (var j = i + 1; j < circles.length; ++j) {
                var intersect = circleCircleIntersection(circles[i],
                                                              circles[j]);
                for (var k = 0; k < intersect.length; ++k) {
                    var p = intersect[k];
                    p.parentIndex = [i,j];
                    ret.push(p);
                }
            }
        }
        return ret;
    }
1325405
public double intersectY(double y)
	{
		if (direction.y == 0)
			return Double.NaN;
		return (y - origin.y) / direction.y;
	}