Calculate the area covered by a union of multiple rectangles. Each rectangle is represented by 4 integers: the first two integers denote the coordinates of the bottom-left corner, and the next two integers denote the coordinates of the top-right corner. The input is provided as a matrix where each row represents one rectangle.
The rectangles can overlap, meaning that simply summing up the areas of each rectangle will not yield the correct total area. Instead, the overlapping regions should be counted only once.
Example:
Given the rectangles [ 4 8 11 10; 6 3 8 10; 16 8 19 11 ] the area covered by the union of these rectangles is 33.
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers9
Suggested Problems
-
Back to basics 9 - Indexed References
463 Solvers
-
Put two time series onto the same time basis
356 Solvers
-
Remove entire row and column in the matrix containing the input values
563 Solvers
-
Create an index-powered vector
954 Solvers
-
34 Solvers
More from this Author53
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Thanks. I learned some new MATLAB commands with this one.
Me too 😄