This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A=[ cos(alfa),-sin(alfa); | |
sin(alfa),+cos(alfa)]; |
以下是示例代码,作用是绘制一个等边三角形,并不断迭代旋转缩小:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beta=[3/6;7/6;11/6;15/6]*pi; | |
x=cos(beta);y=sin(beta); | |
figure(4), | |
line(x,y) | |
xy=[x,y]; | |
alfa=pi/50; | |
A=[ cos(alfa),-sin(alfa); | |
sin(alfa),cos(alfa)]; | |
for k=1:33 | |
xy=0.9*xy*A; | |
x=xy(:,1);y=xy(:,2); | |
line(x,y) | |
end |
所得结果如下:
如果需要逆时针旋转,只需使用A的逆矩阵A^(-1)即可。