public static boolean lineIntersectsRect ( double x1 , double y1 , double x2 , double y2 , double rx , double ry , double rw , double rh ) { double rr = rx + rw , rb = ry + rh ; return ( rx <= x1 && x1 <= rr && ry <= y1 && y1 <= rb ) || ( rx <= x2 && x2 <= rr && ry <= y2 && y2 <= rb ) || linesIntersect ( rx , ry , rr , rb , x1 , y1 , x2 , y2 ) || linesIntersect ( rr , ry , rx , rb , x1 , y1 , x2 , y2 ) ; }
Returns true if the specified line segment intersects the specified rectangle .