code: function d3_geom_polygonIntersect(c, d, a, b) {
    var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0],
        y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1],
        x13 = x1 - x3,
        x21 = x2 - x1,
        x43 = x4 - x3,
        y13 = y1 - y3,
        y21 = y2 - y1,
        y43 = y4 - y3,
        ua = (x43 * y13 - y43 * x13) / (y43 * x21 - x43 * y21);
    return [x1 + ua * x21, y1 + ua * y21];
  }
docs: Intersect two infinite lines cd and ab.