Reputation: 1335
I have a question to you...
Imagine square with size A x A. Now lets simulate circles with diameter of d, randomly distributed within this square, something like on the image below (in this case d's are the same, but its not the rule, they might be also randomly distributed within some range like d1 to d2).
Lets say that circles are described in matrix as:
circles(1, :) = [x, y, d];
circles(2, :) = [x, y, d];
...and so on
where x
, y
are coordinates, d
is diameter. Now the question is, how to simulate this circles, until given crowding parameter c
is reached? c
is simply defined as: c = yellow area / square area (in this case A^2)
.
And the second thing - lets say that everything is simulated and I want to check if some coordinate (x,y) is within or outside yellow area... How to do it? I was doing it by checking if my (x,y) is within area of each circle (but its getting more difficult when instead of circles I use i.e. round shape rectangles), one by one, but there must be some better way of doing it. Thanks for help : )
Upvotes: 3
Views: 1360
Reputation: 21563
Here is an approach that should do the trick:
color = zeros(100)
c = mean(mean(color))
Note, if you only want to use part of the matrix (enable shapes to fall partially out of the picture) this can for example be achieved by using mean(mean(color(11:end-11))
in step 4, ignoring the 10 pixels near the edge.
Now if you want to know whether point (x,y) is yellow, simply check the value of color(x,y)
. Or if you want to ignore the edges check color(x+10,y+10)
Upvotes: 1