happy 发表于 2006-5-10 20:07

[转帖]关于分形树的GUI

% 关于分形树的GUI
% reference:

close all
figure('position',);
s1='Starting size = ';
s2='Minimum Size = ';
s3='Shrink Factor = ';
s4='Angle = ';
ss=69.0;
ms=4.0;
sf=1.85;
A=40.0; % 各参数的初值
axes('position',)
Fractree(ss,ms,sf,A);
set(gcf,'DoubleBuffer','on');
h1=uicontrol(gcf,'style','slider',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','r',...
'SliderStep',,'callback',['a=get(h1,''value'');',...
'ss=fix(10+189*a);','set(t1,''string'',);',...
'Fractree(ss,ms,sf,A);'],'value',(ss-10)/189);
t1=uicontrol(gcf,'style','text',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','b',...
'string','Starting size = 69.0');
h2=uicontrol(gcf,'style','slider',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','r',...
'SliderStep',,'callback',['a=get(h2,''value'');',...
'ms=fix(1+48*a);','set(t2,''string'',);',...
'Fractree(ss,ms,sf,A);'],'value',(ms-1)/48);
t2=uicontrol(gcf,'style','text',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','b',...
'string','Minimum Size = 4.0');
h3=uicontrol(gcf,'style','slider',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','r',...
'SliderStep',,'callback',['a=get(h3,''value'');',...
'sf=fix(150+349*a)/100;','set(t3,''string'',);',...
'Fractree(ss,ms,sf,A);'],'value',(sf*100-150)/349);
t3=uicontrol(gcf,'style','text',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','b',...
'string','Shrink Factor = 1.85');
h4=uicontrol(gcf,'style','slider',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','r',...
'SliderStep',,'callback',['a=get(h4,''value'');',...
'A=fix(179*a);','set(t4,''string'',);',...
'Fractree(ss,ms,sf,A);'],'value',A/179);
t4=uicontrol(gcf,'style','text',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','b',...
'string','Angle = 40.0');
uicontrol(gcf,'style','text',...
'unit','normalized','position',,...
'BackgroundColor',,'ForegroundColor','r',...
'string','Fractal tree V1.0','fontsize',16,...
'fontname','new times roman');

[ 本帖最后由 suffer 于 2006-10-9 21:08 编辑 ]

happy 发表于 2006-5-10 20:08

回复:(happy)[转帖]关于分形树的GUI

function Fractree(ss,ms,sf,A);
% 递归法生成分形树
% ss is Starting size
% ms is Minimum Size
% sf is Shrink Factor
% A is Angle
A=A/180*pi;
L=ss;
jd=pi/2;
z=0;
cla;
hold on;
=recursionN(z,jd,L,ms,sf,A);
hold off
set(gca,'color','k');
xlim([-128,128]);
ylim([-128,128])
function =recursionN(z,jd,L,ms,sf,A);
% 进行递归计算
z1=z+L*exp(i*(jd-A));
z2=z+L*exp(i*(jd+A));
plot(,'y');
if L>ms;
jd=jd-A;
L=L/sf;
=recursionN(z1,jd,L,ms,sf,A);
jd=jd+2*A;
=recursionN(z2,jd,L,ms,sf,A);
jd=jd-A;
L=L*sf;
end


来自萝卜驿站

[ 本帖最后由 suffer 于 2006-10-9 21:09 编辑 ]

天涯青驹 发表于 2013-4-7 16:13

{:{39}:}
页: [1]
查看完整版本: [转帖]关于分形树的GUI