Finding sum of intersecting area of many circles

4 views (last 30 days)
My purpose is to calculate total overlayed area of many circles.(example is below, not the terminal intersecting area)
Here's my flow.
  1. create and plot nine target circles whose radius is about 10 and center coordinates is set in the code
  2. create and plot 18 circles(thought as projectile) whose radius is 50 and center coordinate is repectively normal distribution(e.g. x follows normal distribution and its mu=40, sigma = 400 / y follows normal distribution and its mu = 0, sigma = 50). It could be thought of shoot the projectile on to the target
  3. Among the target's area, calculate the total area overlayed by 18 circles. so it could be damaged area.
seeing the resulted plotted image, it is comparatively easy if i calculate interseting area of two circles(mostly Projectils'e Circle contains target's circle)
but iterating this simulation, specific case occures like 3 or more is overlayd on the target's circle is complicated.
Here's the whole code for procedure of 1 to 2 is processable
but 3 is not
R = 10
% TARGET CENTER COORDINATES%
T_1 = [0, 100];
T_2 = [0, 60];
T_3 = [0, 20];
T_4 = [0, -20];
T_5 = [0, -60];
T_6 = [0, -100];
T_7 = [100-R-R, 80];
T_8 = [100-R-R, 0];
T_9 = [100-R-R, -80];
Target = cat(1, T_1, T_2, T_3, T_4, T_5, T_6, T_7, T_8, T_9)
for i = [1:1:9]
center=[Target(i,1) Target(i,2)];
N=100;
theta=linspace(0,2*pi,N);
X_T=R*cos(theta)+center(1); % Target's X coordinates
Y_T=R*sin(theta)+center(2); % Target's Y coordinates
plot(X_T,Y_T,'color', 'r', 'linewidth',0.8); % Target polotted by red lined circle
hold on
plot(Target(i,1), Target(i,2),'. k'); % Target's center coordinates polotted by red lined circle
axis equal; % set aspect ratio equal
end
sigma_range = 400;
sigma_deflection = 50;
x = 40+(sigma_range).*randn(1,18); % X coordinates of Projectile's center
y = (sigma_deflection).*randn(1,18); % Y coordinates of Projectile's center
for i = [1:1:18]
center=[x(i) y(i)]; % point of impact
r=50; % Radius of projectile's detonation
N=100; % dividing interval of 2pi
theta=linspace(0,2*pi,N); % Angle of Circle(radian)
X=r*cos(theta)+center(1); % X coordinates of raidus of detonation
Y=r*sin(theta)+center(2); % Y coordinates of raidus of detonation
plot(X,Y,'-.'); % plotting the radius of detonation
hold on
% procedure of 3%
if (X-0).^2+(Y-20).^2 <=10.^2 && (X-0).^2+(Y+20).^2<=10.^2 && (X-0).^2+(Y-60).^2<=10.^2 && (X-0).^2+(Y+60).^2<=10.^2 && (X-0).^2+(Y-100).^2<=10.^2 && (X-0).^2+(Y+100).^2<=10.^2 && (X-(100-R-R)).^2+(Y-0).^2<=10.^2 && (X-(100-R-R)).^2+(Y-80).^2<=10.^2 && (X-(100-R-R)).^2+(Y+80).^2<=10.^2
X_d = X;
Y_d = Y;
plot(X_d, Y_d)
hold on
A = 0
A = A + polyarea(X_d, Y_d) % total overalyed area on to the target circles by projectile's circles
end
A
the problem is that if plotting X_d, Y_d, intersecting line of projectile's circle in the radius of targets circle.
so I have no idea of interseting exactly the area of them.
If anyone mind, would you help solve this problem?, Thank you

Accepted Answer

Steven Lord
Steven Lord on 30 Sep 2021
Make polyshape objects, one for each circle. You can then intersect, union, etc. those objects.
  1 Comment
minsung park
minsung park on 12 Oct 2021
thank you for aswering my question.
using intersection, the problem was solved directly!

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!