-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefineFractals.m
110 lines (98 loc) · 3.37 KB
/
defineFractals.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
function defs = defineFractals()
% Helper to create a struct defining the various parameters required for
% each fractal.
% Copyright 2019-2020 The MathWorks, Inc.
idx = 0;
% Burning Ship
idx = idx + 1;
defs(idx).Name = "Burning Ship";
defs(idx).MaxIterations = 5000;
defs(idx).ColormapFcn = @bone;
defs(idx).FixedMinimum = false;
defs(idx).StepsInAnimation = 1000;
defs(idx).CPUFunction = @computeBurningShipCPU;
defs(idx).GPUFunction = @computeBurningShipGPU;
defs(idx).LocationList = readLocationList("burningShipLocations.csv");
% Mandelbrot
idx = idx + 1;
defs(idx).Name = "Mandelbrot";
defs(idx).MaxIterations = 5000;
defs(idx).ColormapFcn = @colormap.jet2;
defs(idx).FixedMinimum = false;
defs(idx).StepsInAnimation = 1000;
defs(idx).CPUFunction = @computeMandelbrotCPU;
defs(idx).GPUFunction = @computeMandelbrotGPU;
defs(idx).LocationList = readLocationList("mandelbrotLocations.csv");
% Mandelar
idx = idx + 1;
defs(idx).Name = "Mandelbar";
defs(idx).MaxIterations = 5000;
defs(idx).ColormapFcn = @colormap.jet2;
defs(idx).FixedMinimum = false;
defs(idx).StepsInAnimation = 1000;
defs(idx).CPUFunction = @computeMandelbarCPU;
defs(idx).GPUFunction = @computeMandelbarGPU;
defs(idx).LocationList = readLocationList("mandelbarLocations.csv");
% Multibrot
idx = idx + 1;
defs(idx).Name = "Multibrot 11";
defs(idx).MaxIterations = 5000;
defs(idx).ColormapFcn = @colormap.jet2;
defs(idx).FixedMinimum = false;
defs(idx).StepsInAnimation = 1000;
defs(idx).CPUFunction = @computeMultibrotCPU;
defs(idx).GPUFunction = @computeMultibrotGPU;
defs(idx).LocationList = readLocationList("multibrot11Locations.csv");
% Newton's method on a cubic
idx = idx + 1;
defs(idx).Name = "Newton's Method (cubic)";
defs(idx).MaxIterations = 50;
defs(idx).ColormapFcn = @colormap.jet2;
defs(idx).FixedMinimum = true;
defs(idx).StepsInAnimation = 1000;
defs(idx).CPUFunction = @computeNewtonCubicCPU;
defs(idx).GPUFunction = @computeNewtonCubicGPU;
defs(idx).LocationList = readLocationList("newtonCubicLocations.csv");
% Newton's method on a trug function
idx = idx + 1;
defs(idx).Name = "Newton's Method (trig)";
defs(idx).MaxIterations = 50;
defs(idx).ColormapFcn = @colormap.jet2;
defs(idx).FlipAxes = false;
defs(idx).FixedMinimum = false;
defs(idx).StepsInAnimation = 1000;
defs(idx).CPUFunction = @computeNewtonTrigCPU;
defs(idx).GPUFunction = @computeNewtonTrigGPU;
defs(idx).LocationList = readLocationList("newtonTrigLocations.csv");
% The "tower of powers" function
idx = idx + 1;
defs(idx).Name = "Tower of Powers";
defs(idx).MaxIterations = 50;
defs(idx).ColormapFcn = @colormap.pinkbone;
defs(idx).FixedMinimum = true;
defs(idx).StepsInAnimation = 100;
defs(idx).CPUFunction = @computeTowerCPU;
defs(idx).GPUFunction = @computeTowerGPU;
defs(idx).LocationList = readLocationList("towerLocations.csv");
end
function locations = readLocationList(filename)
fid = fopen(fullfile('locations',filename), 'rt');
if fid<0
error('fractalViewer:BadLocationRead', ...
'Could not open location list "%s" for reading.', filename);
end
locData = textscan(fid, '%f,%f,%f');
N = size(locData{1}, 1);
if N<1
close(gui.Window);
error('fractalViewer:EmptyLocationFile', 'No locations found in "%s"', filename);
end
locations = struct( ...
'XLim', cell(N, 1), ...
'Y', cell(N, 1 ));
for ii=1:N
locations(ii).XLim = [locData{1}(ii), locData{2}(ii)];
locations(ii).Y = locData{3}(ii);
end
fclose( fid );
end % readLocationList