• Remix
  • Share
  • New Entry

on 1 Nov 2024
  • 74
  • 418
  • 0
  • 3
  • 1954
Cite your audio source here (if applicable):
% Audio Source
% Zeta - Vincent Rubinetti
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent drawpath;
% Define the points as a complex array
path = [345-63i,314-63i,284-64i,256-66i,250-90i,242-118i,234-149i,226-182i,217-216i,209-249i,201-281i,193-310i,187-334i,177-373i,166-409i,155-438i,142-459i,124-471i,94-467i,82-442i,90-420i,102-392i,116-361i,131-330i,143-302i,151-284i,160-264i,170-237i,181-205i,193-171i,205-137i,215-104i,225-75i,223-63i,200-63i,151-64i,113-71i,82-89i,58-112i,39-135i,25-152i,4-153i,4-137i,15-118i,36-88i,65-48i,96-21i,125-7i,147-2i,169-1i,200-1i,230-1i,261-1i,291-1i,322-1i,352-1i,383-1i,413-1i,444-1i,474-1i,505-1i,535-1i,563-2i,579-28i,563-55i,535-62i,505-63i,474-63i,444-63i,413-64i,403-73i,400-90i,393-129i,384-189i,380-231i,380-262i,382-286i,386-306i,391-328i,401-361i,411-392i,419-416i,421-440i,402-466i,367-471i,352-457i,342-434i,334-394i,332-358i,333-320i,335-287i,337-265i,339-242i,345-212i,351-182i,357-152i,363-122i,369-92i,376-62i];
% Number of points
N = numel(path);
% Compute the Discrete Fourier Transform (DFT)
F = fft(path) / N;
% Prepare time values to interpolate the points smoothly
t = linspace(0,1,96);
% Number of Fourier terms to include in reconstruction
num_terms = 24;
% precompute and save the reconstructed path
if f == 1
drawpath = zeros(size(t));
for k=1:96
% Reset for each time point
current_point = F(mod(0,N) + 1) * exp(2*pi*1i*0*t(k));
% Plot each Fourier component as a rotating circle
for n = -num_terms:num_terms
if n==0
continue
end
% Get the index in the DFT result
idx = mod(n,N) + 1;
% Calculate the contribution of the current frequency
term = F(idx) * exp(2*pi*1i*n*t(k));
% Update the current point for this Fourier component
current_point = current_point + term;
end
% Store the point in the reconstruction for visualization
drawpath(k) = current_point;
end
end
% Create a figure for visualization
figure("Color",'k',Position=[0,0,600,600])
hold on;
% Reset for each time point
current_point = F(mod(0,N) + 1) * exp(2*pi*1i*0*t(f));
% Plot each Fourier component as a rotating circle
for n = -num_terms:num_terms
if n==0
continue
end
% Get the index in the DFT result
idx = mod(n,N) + 1;
% Calculate the contribution of the current frequency
term = F(idx) * exp(2*pi*1i*n*t(f));
% Update the current point for this Fourier component
current_point = current_point + term;
% Draw the circle
theta = linspace(0,2*pi,100);
circle = abs(F(idx)) * exp(1i*theta) + current_point - term;
plot(real(circle),imag(circle),Color='#679baa', LineWidth=2);
vlen = abs(term);
% Draw the vector
plot([real(current_point - term),real(current_point)],...
[imag(current_point - term),imag(current_point)],'w',LineWidth=0.1+vlen/50);
end
% Plot the reconstructed shape as it forms
% And create the fading trail
for k=1:96
start = k-1;
if start == 0
start = 96;
end
opacity = 1-mod(f+96-k,96)/128;
plot(real([drawpath(start) drawpath(k)]),imag([drawpath(start) drawpath(k)]),Color=opacity*[1 1 0],LineWidth=2);
end
xlim([-150,750]);
ylim([-650,250]);
hold off;
axis off;
end
Movie
Audio
Remix Tree