用matlab畫出壹個正方形方法:畫壹個正方形(meshgrid),旋轉(旋轉矩陣),平移,畫出來。
具體如下:
clear all
clc
r=3;
point=[6 1];
k=sqrt(3);
the=atan(k);
x_or=[0 r];
y_or=x_or;
[x,y]=meshgrid(x_or,y_or);
x_new=cos(the) * x - sin(the) * y;
y_new=sin(the) * x + cos(the) * y;
mesh(x_new,y_new,ones(size(x_new)));
view(0,90);
axis equal;
hold on;
mesh(x_new+point(1),y_new+point(2),ones(size(x_new)));