code: function getIntersection(a, b, c, d) {
              // http://stackoverflow.com/a/1968345/1440403
              var abVector = b.minus(a);
              var cdVector = d.minus(c);
  
              var denom = -cdVector.x * abVector.y + abVector.x * cdVector.y;
              if (denom === 0) {
                  return null;
              }
  
              var s = (abVector.x * (a.y - c.y) - abVector.y * (a.x - c.x)) / denom;
              var t = (cdVector.x * (a.y - c.y) - cdVector.y * (a.x - c.x)) / denom;
  
              if (-EPSILON <= s && s <= 1 - EPSILON &&
                  -EPSILON <= t && t <= 1 - EPSILON) {
                  return new $.Point(a.x + t * abVector.x, a.y + t * abVector.y);
              }
              return null;
          }
docs: Get intersection point of segments [a,b] and [c,d]