Intersecting rectangle when bottom | Function to find intersection rectangle of given two rectangles . ; Gives bottom - left point of intersection rectangle ; Gives top - right point of intersection rectangle ; No intersection ; Gives top - left point of intersection rectangle ; Gives bottom - right point of intersection rectangle ; bottom - left and top - right corners of first rectangle ; bottom - left and top - right corners of first rectangle ; Function call
function FindPoints ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) { var x5 = Math . max ( x1 , x3 ) ; var y5 = Math . max ( y1 , y3 ) ; var x6 = Math . min ( x2 , x4 ) ; var y6 = Math . min ( y2 , y4 ) ; if ( x5 > x6 y5 > y6 ) { document . write ( " " ) ; return ; } document . write ( " " + x5 + " " + y5 + " " ) ; document . write ( " " + x6 + " " + y6 + " " ) ; var x7 = x5 ; var y7 = y6 ; document . write ( " " + x7 + " " + y7 + " " ) ; var x8 = x6 ; var y8 = y5 ; document . write ( " " + x8 + " " + y8 + " " ) ; } var x1 = 0 , y1 = 0 , x2 = 10 , y2 = 8 ; var x3 = 2 , y3 = 3 , x4 = 7 , y4 = 9 ; FindPoints ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) ;