matlab在二维平面和三维空间中绘制圆形
二维平面绘制圆形
方法1:
x = 10;y = 10;%圆心
r = 5; %半径
rectangle('Position',[x-r,y-r,2*r,2*r],'Curvature',[1,1],...
'FaceColor',[0.5 0.5 0.5],'EdgeColor',[0.5 0.5 0.5],'linewidth',1,'LineStyle','-')
axis([0 100 0 100])
axis square
set(gca,'XTick',0:10:100);
set(gca,'YTick',0:10:100);
方法2:
x = 30; % 圆心
y = 40; % 圆心
r = 15; 半径
theta=0:0.01:2*pi ; % 圆滑性设置
Circle1=x+r*cos(theta);
Circle2=y+r*sin(theta);
plot(Circle1,Circle2,'Color','k','linewidth',1);
axis([0 100 0 100])
axis square
set(gca,'XTick',0:10:100);
set(gca,'YTick',0:10:100);
三维空间绘制圆形
h = 5; % 高度
r = 20; %半径
pos = [20,70]; % 圆心位置
t=0:0.001:(2*pi); % 圆滑性设置
t=[t,0];
plot3(pos(1)+r*sin(t),pos(2)+r*cos(t), h*ones(size(t)))
axis([0 100 0 100])
axis square
set(gca,'XTick',0:10:100);
set(gca,'YTick',0:10:100);
|
请发表评论