Interview Questions

162. How do you check if two pixels are overlapping or not.. ?

Microsoft Interview Questions and Answers


(Continued from previous question...)

162. How do you check if two pixels are overlapping or not.. ?

Question:
How do you check if two pixels are overlapping or not.. ?


maybe an answer2:


If the two rectangles are parameterized by the the top left corner and right bottom corner co-ordinates (with 1 pixel as 1 unit) like
1. For Rectangle R1 (r1x1, r1y1) and (r1x2, r1y2) are the respective top left corner and right bottom corner co-ordinates and
2. For Rectangle R2 (r2x1, r2y1) and (r2x2, r2y2) are the respective top left corner and right bottom corner co-ordinates then the rectangles overlap if the following conditions are satisfied:
((r1x1 > r2x1) && (r1y1 > r2y1) && (r1x1 < r2x2) && (r1y1 < r2y2)) If the above condition is not satisfied, then the rectangles don't overlap

(Continued on next question...)

Other Interview Questions