Matlab 坐标转换,图形旋转

%
%Transform Coordinate
figure(1);
clf;
x = [1 2 3 0.5 3.5 3.5 0.5];
y = [2 2 1 0.5 0.5 2.5 2.5];
x = x - 0.5;
y = y - 0.5;
plot(x(1),y(1),'bo-','MarkerSize',20,'MarkerFaceColor','r');
hold on;
plot(x(2),y(2),'bo-','MarkerSize',20,'MarkerFaceColor','g');
hold on;
plot(x(3),y(3),'bo-','MarkerSize',20,'MarkerFaceColor','b');
hold on;
line([x(4),x(5)],[y(4),y(5)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
line([x(5),x(6)],[y(5),y(6)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
line([x(6),x(7)],[y(6),y(7)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
line([x(7),x(4)],[y(7),y(4)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
%下面为画箭头命令
annotation('arrow',[0.131 0.131],[0.9 1]);
annotation('arrow',[0.9 1],[0.1102 0.1102]);
%调整图片大小,使箭头处于合适位置
set (gcf,'Position',[200,100,890,820], 'color','w');
axis([0 4 0 4]);
set(gca,'xtick',[],'xticklabel',[],'ytick',[],'yticklabel',[]);
box off;

figure(2);
x = [1 2 3 0.5 3.5 3.5 0.5];
y = [2 2 1 0.5 0.5 2.5 2.5];
for i = 1 : 1 : 7
    tmp1 = x(i);
    tmp2 = y(i);
    x(i) = tmp1 * cos(-20*pi/180) + tmp2 * sin(-20*pi/180) + 0.5;
    y(i) =-tmp1 * sin(-20*pi/180) + tmp2 * cos(-20*pi/180); 
end
plot(x(1),y(1),'bo-','MarkerSize',20,'MarkerFaceColor','r');
hold on;
plot(x(2),y(2),'bo-','MarkerSize',20,'MarkerFaceColor','g');
hold on;
plot(x(3),y(3),'bo-','MarkerSize',20,'MarkerFaceColor','b');
hold on;
line([x(4),x(5)],[y(4),y(5)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
line([x(5),x(6)],[y(5),y(6)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
line([x(6),x(7)],[y(6),y(7)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
line([x(7),x(4)],[y(7),y(4)],'LineWidth',4,'Color',[0.5 0.5 0.5]);
%下面为画箭头命令
annotation('arrow',[0.131 0.131],[0.9 1]);
annotation('arrow',[0.9 1],[0.1102 0.1102]);
%调整图片大小,使箭头处于合适位置
set (gcf,'Position',[200,100,890,820], 'color','w');
axis([0 4 0 4]);
set(gca,'xtick',[],'xticklabel',[],'ytick',[],'yticklabel',[]);
box off;

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值