code: static Point2d intersection(final double x1, final double y1, final double x2, final double y2, final double x3,
              final double y3, final double x4, final double y4) {
          final double x = ((x2 - x1) * (x3 * y4 - x4 * y3) - (x4 - x3) * (x1 * y2 - x2 * y1))
                  / ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4));
          final double y = ((y3 - y4) * (x1 * y2 - x2 * y1) - (y1 - y2) * (x3 * y4 - x4 * y3))
                  / ((x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4));
          return new Point2d(x, y);
      }
docs: Calculate the intersection of two lines described by the points (x1,y1 -> x2,y2) and (x3,y3
  -> x4,y4).
  
  @param x1 first x coordinate of line 1
  @param y1 first y coordinate of line 1
  @param x2 second x coordinate of line 1
  @param y2 second y coordinate of line 1
  @param x3 first x coordinate of line 2
  @param y3 first y coordinate of line 2
  @param x4 first x coordinate of line 2
  @param y4 first y coordinate of line 2
  @return the point where the two lines intersect (or null)
  @see <a href="http://en.wikipedia.org/wiki/Line–line_intersection">Line-line intersection,
  Wikipedia</a>