Two rectangles to find the intersection:
Rectangle 1:
left_bottom point(R1_x1,R1_y1) | right_top point(R1_x2,R1_y2)
Rectangle 2:
left_bottom point(R2_x1,R2_y1) | right_top point(R2_x2,R2_y2)
Intersection:
x_overlap = Math.max(0, Math.min(R1_x2,R2_x2) - Math.max(R1_x1,R2_x1))
y_overlap = Math.max(0, Math.min(R1_y2,R2_y2) - Math.max(R1_y1,R2_y1));
return x_overlap*y_overlap;
Friday, April 25, 2014
Subscribe to:
Post Comments (Atom)
A must read post! Good way of describing and pleasure piece of writing. Thanks!
ReplyDeleteggtu ba 1st year exam result 2021 | ggtu ba 2nd year exam result 2021.