⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chaoticfractaltree.m

📁 分形计算的几个程序原码
💻 M
字号:
function ChaoticFractalTree; 
% Chaotic Fractal Tree 
% reference: 
% http://www.kirupa.com/developer/actionscript/chaos_fractal.htm 
% 

% Constants: 
max_sub_branch = 4; 
max_sub_angle=3*pi/4 ; 
max_size=6; 
branch_length=50; 

% function call 

hold on 
makeBranch(200,300,branch_length,pi/2,max_size); 
title('please double click the mouse and redraw') 
set(gcf,'ButtonDownFcn',['t=get(gcf,''SelectionType'');',... 
   'if t(1)==''o'';close;',... 
   'ChaoticFractalTree;end']) 
%% Function 
function makeBranch (start_x,start_y,leng,angl,siz); 
% Constants: 
max_sub_branch = 4; 
max_sub_angle=3*pi/4 ; 
branch_length=50; 
if siz>0; 
   z=start_x+start_y*i; 
   z_end=z+leng*exp(i*angl); 
   plot([z,z_end],'linewidth',siz); 
   sub_branch=rand*(max_sub_branch-1)+2; 
   branch_length_dimin=.5+rand/2; 
   end_x=real(z_end); 
   end_y=imag(z_end); 
   for k=0:sub_branch; 
       newLength=leng*branch_length_dimin; 
       newAngle =angl+rand*max_sub_angle-max_sub_angle/2; 
       newSize=siz-1; 
       makeBranch(end_x,end_y,newLength,newAngle,newSize); 
   end 
end 

%实现鼠标双击重绘
axes; 
title('please double click the mouse and redraw') 
set(gcf,'ButtonDownFcn',['t=get(gcf,''SelectionType'');',... 
   'if t(1)==''o'';cla;',... 
   'ChaoticFractalTree;end']) 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -