声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3108|回复: 2

[GUI界面] [转帖]关于分形树的GUI

[复制链接]
发表于 2006-5-10 20:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
  1. % 关于分形树的GUI
  2. % reference:

  3. close all
  4. figure('position',[135 105 646 342]);
  5. s1='Starting size = ';
  6. s2='Minimum Size = ';
  7. s3='Shrink Factor = ';
  8. s4='Angle = ';
  9. ss=69.0;
  10. ms=4.0;
  11. sf=1.85;
  12. A=40.0; % 各参数的初值
  13. axes('position',[0.5,0.1,0.45,0.8])
  14. Fractree(ss,ms,sf,A);
  15. set(gcf,'DoubleBuffer','on');
  16. h1=uicontrol(gcf,'style','slider',...
  17. 'unit','normalized','position',[0.02,0.7,0.4,0.04],...
  18. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','r',...
  19. 'SliderStep',[0.01,0.01],'callback',['a=get(h1,''value'');',...
  20. 'ss=fix(10+189*a);','set(t1,''string'',[s1,num2str(ss)]);',...
  21. 'Fractree(ss,ms,sf,A);'],'value',(ss-10)/189);
  22. t1=uicontrol(gcf,'style','text',...
  23. 'unit','normalized','position',[0.02,0.75,0.4,0.04],...
  24. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','b',...
  25. 'string','Starting size = 69.0');
  26. h2=uicontrol(gcf,'style','slider',...
  27. 'unit','normalized','position',[0.02,0.6,0.4,0.04],...
  28. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','r',...
  29. 'SliderStep',[0.01,0.01],'callback',['a=get(h2,''value'');',...
  30. 'ms=fix(1+48*a);','set(t2,''string'',[s2,num2str(ms)]);',...
  31. 'Fractree(ss,ms,sf,A);'],'value',(ms-1)/48);
  32. t2=uicontrol(gcf,'style','text',...
  33. 'unit','normalized','position',[0.02,0.65,0.4,0.04],...
  34. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','b',...
  35. 'string','Minimum Size = 4.0');
  36. h3=uicontrol(gcf,'style','slider',...
  37. 'unit','normalized','position',[0.02,0.5,0.4,0.04],...
  38. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','r',...
  39. 'SliderStep',[0.01,0.01],'callback',['a=get(h3,''value'');',...
  40. 'sf=fix(150+349*a)/100;','set(t3,''string'',[s3,num2str(sf)]);',...
  41. 'Fractree(ss,ms,sf,A);'],'value',(sf*100-150)/349);
  42. t3=uicontrol(gcf,'style','text',...
  43. 'unit','normalized','position',[0.02,0.55,0.4,0.04],...
  44. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','b',...
  45. 'string','Shrink Factor = 1.85');
  46. h4=uicontrol(gcf,'style','slider',...
  47. 'unit','normalized','position',[0.02,0.4,0.4,0.04],...
  48. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','r',...
  49. 'SliderStep',[0.01,0.01],'callback',['a=get(h4,''value'');',...
  50. 'A=fix(179*a);','set(t4,''string'',[s4,num2str(A)]);',...
  51. 'Fractree(ss,ms,sf,A);'],'value',A/179);
  52. t4=uicontrol(gcf,'style','text',...
  53. 'unit','normalized','position',[0.02,0.45,0.4,0.04],...
  54. 'BackgroundColor',[0.8 0.8 0.8],'ForegroundColor','b',...
  55. 'string','Angle = 40.0');
  56. uicontrol(gcf,'style','text',...
  57. 'unit','normalized','position',[0.04,0.85,0.3,0.12],...
  58. 'BackgroundColor',[0.8 0.8 0.9],'ForegroundColor','r',...
  59. 'string','Fractal tree V1.0','fontsize',16,...
  60. 'fontname','new times roman');
复制代码

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

本帖被以下淘专辑推荐:

回复
分享到:

使用道具 举报

 楼主| 发表于 2006-5-10 20:08 | 显示全部楼层

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

  1. function Fractree(ss,ms,sf,A);
  2. % 递归法生成分形树
  3. % ss is Starting size
  4. % ms is Minimum Size
  5. % sf is Shrink Factor
  6. % A is Angle
  7. A=A/180*pi;
  8. L=ss;
  9. jd=pi/2;
  10. z=0;
  11. cla;
  12. hold on;
  13. [z,jd,L]=recursionN(z,jd,L,ms,sf,A);
  14. hold off
  15. set(gca,'color','k');
  16. xlim([-128,128]);
  17. ylim([-128,128])
  18. function [z,jd,L]=recursionN(z,jd,L,ms,sf,A);
  19. % 进行递归计算
  20. z1=z+L*exp(i*(jd-A));
  21. z2=z+L*exp(i*(jd+A));
  22. plot([z1,z,z2],'y');
  23. if L>ms;
  24. jd=jd-A;
  25. L=L/sf;
  26. [z1,jd,L]=recursionN(z1,jd,L,ms,sf,A);
  27. jd=jd+2*A;
  28. [z2,jd,L]=recursionN(z2,jd,L,ms,sf,A);
  29. jd=jd-A;
  30. L=L*sf;
  31. end
复制代码



来自萝卜驿站

[ 本帖最后由 suffer 于 2006-10-9 21:09 编辑 ]
发表于 2013-4-7 16:13 | 显示全部楼层
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-29 00:38 , Processed in 0.060155 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表