• Remix
  • Share
  • New Entry

on 30 Nov 2023
  • 8
  • 5
  • 2
  • 0
  • 567
drawframe(1);
Write your drawframe function below
function drawframe(f)
%% Complex domain plot
%% Reference: https://copyprogramming.com/howto/how-can-i-generate-this-domain-coloring-plot
num_frames = 48;
range = pi; % xy limits
res = 2000; % resolution
t = (f-1)/(num_frames-1);
fun = @(Z) sin(Z).*sin(pi*t);
imshow(domainPlot(fun,pi,res));
% generate grid
function Z = getComplexGrid(range, n)
r = linspace(-range, range, n);
[X, Y] = meshgrid(r, -r);
Z = complex(X,Y);
end
% calcualte HSV values
function HSV = getComplexHSB(Z)
h = (angle(Z)+pi+0.05)/ (2 * pi);
s = abs(sin(2 * pi * abs(Z)));
v = ones(size(Z));
HSV = cat(3,h,s, v);
end
function resultImage = domainPlot(func, range, n)
Z = getComplexGrid(range, 2 * n);
fZ = func(Z);
HSB = getComplexHSB(fZ);
rgbImage = hsv2rgb(HSB);
resultImage = imresize(rgbImage, [n/2, n/2], 'method', 'bilinear');
end
end
Animation
Remix Tree