python实现小圆覆盖大圆:https://blog.csdn.net/qq_41845823/article/details/118860729
*以下是MATLAB
的实现代码:
function []=plot1(x,y,r)
theta=0:0.01:2*pi;
Circle1=x+r*cos(theta);
Circle2=y+r*sin(theta);
c=[123,14,52];
plot(Circle1,Circle2,'c',1);
axis equal;
end
x=0
%disp(['x= ',num2str(x)])
m=x;
temp=x;
y=0
%disp(['y= ',num2str(y)])
n=y;
x=temp;
a=0;
r=60.5;
z=r*(3^(1/2))/2;
p=x;
q=p;
j=y;
for y=j:3/2*r:1100
for x=p:r*3^(1/2):1100
if sqrt(x^2+y^2)-1000<r
plot1(x,y,r)
hold on
a=a+1;
end
end
for x=p-r*(3^(1/2)):-r*(3^(1/2)):-1100
if sqrt(x^2+y^2)-1000<r
plot1(x,y,r)
hold on
a=a+1;
end
end
p=p+z;
end
p=q-z;
for y=j-3/2*r:-3/2*r:-1100
for x=p:r*(3^(1/2)):1100
if sqrt(x^2+y^2)-1000<r
plot1(x,y,r)
hold on
a=a+1;
end
end
for x=p-r*(3^(1/2)):-r*(3^(1/2)):-1100
if sqrt(x^2+y^2)-1000<r
plot1(x,y,r)
hold on
a=a+1;
end
end
p=p+z;
end
%if a<=b
%b=a
%disp(b)
%if a<=367
disp(['x= ',num2str(m)])
disp(['y= ',num2str(n)])
disp(a)
end
plot1(0,0,1000);
%生成的图像输出为文件
print -dpng 'myplot.png';
- 生成的图像如下图所示:
不得不说,MATLAB
还是工业界的顶级软件,在以前的一篇python实现小圆覆盖大圆
的文章中生成的图片可以看出质量不是很高,放大后像素点模糊不堪,而放眼看下matlab生成的图像放大后:
细节一眼就看出来是否覆盖了大圆