Creating an array and ruling out overlapping circles
1 view (last 30 days)
Show older comments
Jonathan
on 23 Mar 2020
Answered: Walter Roberson
on 23 Mar 2020
Hi Everyone!
I was undertaking a project where I am given various rectangles of various X and Y dimension. Within this rectangle there are numerous amounts of overlapping circles including some that fall outside the rectangle boundaries.
My goal is to find the percentage of the rectangle that is covered by the rectangle.
I'm not sure of the best way to do this and the functions involved? This is what I planned to do.
My thought process was to:
1) create an array of 0 with the rectangle's width and height.
2) If the circle intersects the rectangle (and the array), the values in the array are switched to a 1
3) Then calculate percentages of 1 over the inital amount of 0s
Does this idea make sense to everyone?
Which functions do I use here? (especially in step 1 and 2). (I'm not the best with matrices)
Any assistance would be great thanks!
0 Comments
Accepted Answer
Walter Roberson
on 23 Mar 2020
The above link shows you ways to set values in a circle inside an array.
Once you had done that for all of the circles, 100*mean() of the array gives you the occupied percentage.
0 Comments
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!