How to generate a mesh of two connected / overlapping circles?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
We want to create a mesh of the geometry, as can be seen in the figure.
However, because of the overlap of two circles, the mesh does not connect the two circles.
Can someone help us out?
Thank you in advance.
clear all
close all
%%
xCenter1 = 0.7;
yCenter1 = 0;
xCenter2 = 1.5;
yCenter2 = 0;
theta = 0 : 0.01 : 2*pi;
radius1 = 1;
radius12 = 0.9;
radius2 = 1;
radius22 =0.5;
M = 10;
N = 100;
nR1 = linspace(radius1,radius12,M) ;
nR2 = linspace(radius2,radius22,M);
nT = linspace(0,2*pi,N) ;
[R1, T] = meshgrid(nR1,nT) ;
[R2, T] = meshgrid(nR2,nT) ;
%%
%generate 2 circles with parameters above.
x1 = radius1 * cos(theta) + xCenter1;
x11 = radius12*cos(theta)+xCenter1;
y1 = radius1 * sin(theta) + yCenter1;
y11=radius12*sin(theta)+yCenter1;
x2 = radius2 * cos(theta) + xCenter2;
x22 =radius22*cos(theta)+xCenter2;
y2 = radius2 * sin(theta) + yCenter2;
y22=radius22*sin(theta)+yCenter2;
%%
%find distance from each circle center to the other circle's infringing points.
dC2 = sqrt((x1-xCenter2).^2+(y1-yCenter2).^2)>=radius2;
dC22 = sqrt((x11-xCenter2).^2+(y11-yCenter2).^2)>=radius2;
%%
figure
set(gcf,'color','w') ;
axis equal
axis off
box on
hold on
plot(x1(dC2), y1(dC2),'k.',x11(dC22),y11(dC22),'k.',x2,y2,'k.',x22,y22,'k.');
%%
%Calculating coordinates in a matrix
mx1 = R1 .* cos(T) + xCenter1;
mx11 = R1 .*cos(T)+ xCenter1;
my1 = R1 .* sin(T) + yCenter1;
my11=R1 .* sin(T) + yCenter1;
mx2 = R2 .* cos(T) + xCenter2;
mx22 = R2 .* cos(T) + xCenter2;
my2 = R2 .* sin(T) + yCenter2;
my22= R2 .* sin(T)+yCenter2;
mdC2 = sqrt((mx1-xCenter2).^2+(my1-yCenter2).^2)>=radius2;
%creating a figure
figure
set(gcf,'color','w') ;
axis equal
axis off
box on
hold on
%defining the boundaries for the for loop
[m,n] = size(mx1);
for i=1:m
plot(mx2(i,:),my2(i,:),'k','linewidth',1.5);
if mdC2(i,:) == 1
plot(mx1(i,:),my1(i,:),'k','linewidth',1.5);
end
end
%plot(x1(dC2), y1(dC2),'k.',x11(dC22),y11(dC22),'k.',x2,y2,'k.',x22,y22,'k.');
for j=1:n
plot(mx2(:,j),my2(:,j),'k','linewidth',1.5);
%if mdC2(j) == 1
%plot(mx1(:,j),my1(:,j),'k','linewidth',1.5);
% % if mdC2(j) == 1
%end
%
end
grid on;
0 Commenti
Risposte (1)
Vedere anche
Categorie
Scopri di più su Computational Geometry in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!