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

📄 fractal_explorer.m

📁 Fractal Explorer GUI-based program for exploring and studying the most common form of fractals, c
💻 M
📖 第 1 页 / 共 5 页
字号:
% hObject    handle to Untitled_15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


ctes = {'2.723456789' '2.123456789' '1.12345' '1.54321';
    '-2.01' '-1.01' '0.51' '1.49'; '2.05' '1.728' '2.08' '0.45';
    '2.723' '2.123' '2' '1.54321'; '3' '1.86' '2.06' '0.45';
    '2.723' '2.123' '2.9' '1.54321'; '2.15' '1.75' '0.89' '1.4';
    '2.05' '1.728' '0.89' '0.29'; '3' '2.84' '1' '0.8';
    '2.723' '2.123' '2.9' '2.6'; '-2.99' '1.43' '0.51' '1.49'};
msg = sprintf('Pickover Dynamic System:\n\nIterations on the system:\nx = sin(b*y)+c*sin/b*x)\ny = sin(a*x)+d*sin(a*y)\n\nSpecify the constants:\n\n');
if ~isfield(handles, 'pickover_params')
    handles.pickover_params = {ctes{unidrnd(length(ctes)), :}};
elseif isempty(handles.pickover_params)
    handles.pickover_params = {ctes(unidrnd(length(ctes)), :)};
end
handles.pickover_params = localdlg({[msg 'a:'], 'b:', 'c:', 'd:'}, 'Pickover System', [1 10], handles.pickover_params, ...
    ['usrdta = get(gcbf, ''UserData''); z = unidrnd(length(usrdta.Data)); for i=1:length(usrdta.EditHandles), '...
        'set(usrdta.EditHandles(i), ''String'', str2num(usrdta.Data{z,i})); end;'], 'Cool Params', ctes);
if isempty(handles.pickover_params)
    return;
end
for i = 1:length(handles.pickover_params)
    handles.ctes(i) = str2num(handles.pickover_params{i});
end
handles.mode = -4;
x = 0.1;
y = 0.1;
set(handles.fractal_explorer, 'KeyPressFcn', ';');
set(handles.menu_julia_mouse, 'Enable', 'off'); % disable julia
handles = fillupdescription(handles);
set(handles.txt_help, 'String', sprintf('Press any key to stop.\nTo zoom in during the calculation,\nselect a zone with the mouse.\nTo zoom out, right-click.'));
set(handles.txt_help, 'Visible', 'on');
axes(handles.main_axis);
if isfield(handles, 'main_image')
    try delete(handles.main_image); end
end

set(handles.main_axis, 'Drawmode','normal');
plot(0, 0, 'k.', 'MarkerSize', 1);
set(handles.main_axis, ...
    'XLim',[-4 4],'YLim',[-4 4], ...
    'XTick',[],'YTick',[], ...
    'Drawmode','fast', ...
    'Visible','on', ...
    'NextPlot','add', ...
    'Color', [0 0 0]);
xlabel('X');
ylabel('Y');
serie = [x y; zeros(9999, 2)];
lne_body = line( ...
    'color','y', ...
    'Marker','.', ...
    'LineStyle', 'none', ...
    'MarkerSize',1, ...
    'erase','none', ...
    'xdata',[],'ydata',[]);
lne_tail=line( ...
    'color',[0.5 0.5 1], ...
    'Marker','.', ...
    'LineStyle', 'none', ...
    'MarkerSize',1, ...
    'erase','none', ...
    'xdata',[],'ydata',[]);
lne_trace=line( ...
    'color',[0.3 0.3 1], ...
    'Marker','.', ...
    'LineStyle', 'none', ...
    'MarkerSize',1, ...
    'erase','none', ...
    'xdata',[],'ydata',[]);

set(handles.fractal_explorer, 'CurrentCharacter', '?);
cchr = get(handles.fractal_explorer, 'CurrentCharacter');
zoom on;
while strcmp(get(handles.fractal_explorer, 'CurrentCharacter'), cchr)
    tmp = [];
    for i = 1:20
        xx = sin(handles.ctes(2)*y)+handles.ctes(3)*sin(handles.ctes(2)*x);
        y = sin(handles.ctes(1)*x)+handles.ctes(4)*sin(handles.ctes(1)*y);
        x = xx;
        tmp = [tmp; x y];
    end
    serie = [tmp; serie(1:end-20,:)];
    set(lne_trace,'xdata',serie(5000:end-2, 1),'ydata',serie(5000:end-2, 2));
    set(lne_tail,'xdata',serie(41:4999, 1),'ydata',serie(41:4999, 2));
    set(lne_body,'xdata',serie(1:40,1),'ydata',serie(1:40,2));
    drawnow;
end
hold off;
set(handles.fractal_explorer, 'KeyPressFcn', '');
set(handles.txt_help, 'Visible', 'off');
guidata(hObject, handles);


% --------------------------------------------------------------------
function menu_head_image_Callback(hObject, eventdata, handles)
% hObject    handle to menu_head_image (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_head_colors_Callback(hObject, eventdata, handles)
% hObject    handle to menu_head_colors (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_color_standard_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_standard (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'default');
colormap(handles.preview_axis, 'default');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);

% --------------------------------------------------------------------
function menu_color_copper_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_copper (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'copper');
colormap(handles.preview_axis, 'copper');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);

% --------------------------------------------------------------------
function menu_color_psy_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_psy (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'flag');
colormap(handles.preview_axis, 'flag');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);

% --------------------------------------------------------------------
function menu_color_hot_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_hot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'hot');
colormap(handles.preview_axis, 'hot');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);



% --------------------------------------------------------------------
function menu_color_cool_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_cool (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'cool');
colormap(handles.preview_axis, 'cool');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);

% --------------------------------------------------------------------
function menu_color_spring_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_spring (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


colormap(handles.main_axis, 'spring');
colormap(handles.preview_axis, 'spring');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);

% --------------------------------------------------------------------
function menu_color_summer_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_summer (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'summer');
colormap(handles.preview_axis, 'summer');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);

% --------------------------------------------------------------------
function menu_color_autumn_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_autumn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'autumn');
colormap(handles.preview_axis, 'autumn');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);

% --------------------------------------------------------------------
function menu_color_winter_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_winter (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

colormap(handles.main_axis, 'winter');
colormap(handles.preview_axis, 'winter');
handles = managecolorticks(handles);
set(hObject, 'Checked', 'on');
guidata(hObject, handles);


% --------------------------------------------------------------------
function menu_head_colorshift_Callback(hObject, eventdata, handles)
% hObject    handle to menu_head_colorshift (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_color_shift_one_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_shift_one (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

mapp = colormap(gca);
mapp = [mapp(2:end, :); mapp(1, :)];
colormap(handles.main_axis, mapp);
colormap(handles.preview_axis, mapp);


% --------------------------------------------------------------------
function menu_color_shift_conti_Callback(hObject, eventdata, handles)
% hObject    handle to menu_color_shift_conti (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.fractal_explorer, 'KeyPressFcn', ';');
set(handles.txt_help, 'String', sprintf('Press any key to stop.'));
set(handles.txt_help, 'Visible', 'on');
axes(handles.main_axis);
s_space = get(handles.main_image, 'CData');
handles.space = s_space;
set(handles.fractal_explorer, 'CurrentCharacter', '?);
cchr = get(handles.fractal_explorer, 'CurrentCharacter');
while strcmp(get(handles.fractal_explorer, 'CurrentCharacter'), cchr)
    handles.space = mod(handles.space + 1, 127);
    set(handles.main_image, 'EraseMode', 'none');
    set(handles.main_image, 'CData', handles.space);
    drawnow;
end
set(handles.main_image, 'CData', s_space);
set(handles.fractal_explorer, 'KeyPressFcn', '');
set(handles.txt_help, 'Visible', 'off');
guidata(hObject, handles);


% --------------------------------------------------------------------
function menu_head_2d_Callback(hObject, eventdata, handles)
% hObject    handle to menu_head_2d (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_head_3d_Callback(hObject, eventdata, handles)
% hObject    handle to menu_head_3d (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_quadratic_Callback(hObject, eventdata, handles)
% hObject    handle to menu_quadratic (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% ctes:
tmp = ['amtmnqqxuyga';'cvqkghqtphte';'fircderrpvld';'giietpiqrrul';'glxoesfttpsv';'gxqsnskeectx';'hguhdphnsgoh';'ilibvpkjwgrr';...
        'lufbbfisgjys';'mcrbipophtbn';'mdvaidoyhyea';'odgqcnxodnya';'qffvslmjjgcr';'uwacxdqigkhf';'vbwnbdelyhul';'wncslflgihgl'];
for i = 1:size(tmp, 1)
    for j = 1:size(tmp,2)
        n_val = -1.2+0.1*(double(tmp(i, j))-97);
        if abs(n_val) < 1e-3
            n_val = 0;
        end
        ctes{i, j} = num2str(n_val);
    end
end
msg = sprintf(['Complete Quadratic Map:\n\nx = a+ bx+ cx^2+ dxy+ ey+ fy^2\ny = g + hx+ ix^2+ jxy+ ky+ ly^2\n\n']);
if ~isfield(handles, 'quadmap_params')
    handles.quadmap_params = {ctes{unidrnd(length(ctes)), :}};
elseif isempty(handles.quadmap_params)
    handles.quadmap_params = {ctes(unidrnd(length(ctes)), :)};
end
handles.quadmap_params = localdlg({[msg 'a:'], 'b:', 'c:', 'd:', 'e:', 'f:', 'g:', 'h:', 'i:', 'j:', 'k:', 'l:'}, 'Quadratic Map', [1 10], ...
    handles.quadmap_params, ['usrdta = get(gcbf, ''UserData''); z = unidrnd(length(usrdta.Data)); for i=1:length(usrdta.EditHandles), '...
        'set(usrdta.EditHandles(i), ''String'', str2num(usrdta.Data{z,i})); end;'], 'Cool Params', ctes);
if isempty(handles.quadmap_params)
    return;
end
for i = 1:length(handles.quadmap_params)
    handles.ctes(i) = str2num(handles.quadmap_params{i});
end
handles.mode = -5;
x = 0.1;
y = 0.1;
set(handles.fractal_explorer, 'KeyPressFcn', ';');
set(handles.menu_julia_mouse, 'Enable', 'off'); % disable julia
handles = fillupdescription(handles);
set(handles.txt_help, 'String', sprintf('Press any key to stop.\nTo zoom in during the calculation,\nselect a zone with the mouse.\nTo zoom out, right-click.'));
set(handles.txt_help, 'Visible', 'on');

⌨️ 快捷键说明

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