• Remix
  • Share
  • New Entry

on 23 Oct 2024
  • 34
  • 192
  • 0
  • 0
  • 1124
Cite your audio source here (if applicable): Ameya Deoras - Flames of the Infinite Mandelbrot © 2019
drawframe(1);
Write your drawframe function below
function drawframe(f)
% Mandelbrot zoom animation with hot colormap
Npt = 600; % Grid size Npt-by-Npt
Nframe = 96;
if nargin < 2
nIter = 235+f*7; % Num iterations to calculate mandelbrot membership. As we zoom in, more iterations are required
unBndThresh = 10; % Threshold above which point is considered unbounded
vizThresh = 10; % Threshold for visualization
end
centerStart = [-1 .276];
centerEnd = [-.9965 .2885];
widthStart = [.06 .06];
widthEnd = [.003 .003];
scale = (widthStart./widthEnd).^(1/Nframe);
rateFactor = widthStart./scale.*((1-(1./scale).^Nframe)./(1-1./scale));
rate = (centerEnd-centerStart)./rateFactor;
% Test rate - validation of above formula
if 0
c = centerStart; w = widthStart;
for i = 1:Nframe
w = w./scale;
c = c + rate.*w;
end
assert(max(abs(c-centerEnd))<1e-13, 'Error in centerEnd');
assert(max(abs(w-widthEnd))<1e-13, 'Error in widthEnd');
end
% Calculate mandelbrot frame
rateFactor = widthStart./scale.*((1-(1./scale).^f)./(1-1./scale));
c = centerStart + rate.*rateFactor;
w = widthStart./(scale.^f);
xlim = c(1) + [-1 1]*w(1)/2;
ylim = c(2) + [-1 1]*w(2)/2;
x = linspace(xlim(1), xlim(2), Npt);
y = linspace(ylim(1), ylim(2), Npt);
[X,Y] = meshgrid(x,y);
c = X + 1j*Y;
[ind, ~, n] = isSetMember(c, nIter, unBndThresh, vizThresh); % n(i,j) is number of iterations before z(i,j) crosses threshold
n(ind) = NaN; % Points within set
n = n/nanmean(n(:)); % Normalize
% Plot
imagesc(x, y, n);
colormap hot;
set(gca, 'YDir','normal');
axis square; axis off
% Function to calculate Mandelbrot set membership
function [i,z,n] = isSetMember(c, nIter, ubThresh, vizThresh)
z = c; n = c*0;
for k = 1:nIter
z = z.^2 + c;
n(abs(z)<vizThresh) = k+1;
end
i = abs(z) < ubThresh;
end
end
Movie
Audio
Remix Tree