中国国旗的难点就在于转星星。。。本人于是用了下极坐标转换函数。。。
话不多说,上程序!
function Chineseflag()
flag = zeros(13,40);
show = flag;
show(end+1,1) = 0;
show(end,end+1) = 1;
pcolor(1:41,1:14,show);
colormap hsv
shading flat
axis off
hold on
Chinesestar(1.5,6,11,0)
Chinesestar(0.5,12,8,pi/5)
Chinesestar(0.5,15,9.5,pi/30)
Chinesestar(0.5,15,11.5,pi/8)
Chinesestar(0.5,12,13,-pi/15)
hold off
上面是主程序
接下来是画星星。。。
function Chinesestar(r,x,y,z)
A = r*[-cos(pi*1/10),-sin(pi*1/10)*tan(pi*2/10),0,sin(pi*1/10)*tan(pi*2/10),cos(pi*1/10),sin(pi*1/10)/cos(pi*2/10)*cos(pi*1/10),cos(pi*3/10),0,-cos(pi*3/10),-sin(pi*1/10)/cos(pi*2/10)*cos(pi*1/10),-cos(pi*1/10)];
B = r*[sin(pi*1/10),sin(pi*1/10),1,sin(pi*1/10),sin(pi*1/10),-sin(pi*1/10)/cos(pi*2/10)*sin(pi*1/10),-sin(pi*3/10),-sin(pi*1/10)/cos(pi*2/10),-sin(pi*3/10),-sin(pi*1/10)/cos(pi*2/10)*sin(pi*1/10),sin(pi*1/10)];
[C,D] = cart2pol(A,B);
C = C + z;
[A,B] = pol2cart(C,D);
A = 2*A+x;
B = B+y;
fill(A,B,[1,0.7,0])
hold on
plot(A,B,’y-’)