• Remix
  • Share
  • New Entry

  • Adam Danz

  • /
  • Rotating Flower Batik (remix, see original by Dhimas)

on 24 Nov 2023
  • 15
  • 40
  • 1
  • 2
  • 711
drawframe(1);
Remix of Dhimas's Graph Equation of "Flower Batik" on Cartesian Plane
Write your drawframe function below
function drawframe(f)
if mod(f,2)==0; return; end % Skip every second frame
persistent p
if f==1
p = linspace(-0,1,50);
maxxy = 12;
syms x y
m=(2*cos(x).*cos(y)+abs(sin(3*x).*sin(y)-sin(x).*sin(3*y)))^(-4);
eqn = (2*cos(x).*cos(y))^2+m == 2.5 + p(48);
h =fimplicit(eqn, maxxy*[-1 1 -1 1], MeshDensity=1000,Visible='off');
hold on
nc = 13;
color = turbo(nc+2);
color(1:2,:) = []; % Remove the darker blues
isn = [0,find(isnan(h.XData)),numel(h.XData)+1];
maxDist = sqrt(2*maxxy^2);
p = gobjects(numel(isn)-1,1);
for i = 1:numel(isn)-1
idx = isn(i)+1:isn(i+1)-1;
xd = h.XData(idx);
yd = h.YData(idx);
distance = hypot(mean(xd),mean(yd));
c = round(distance/maxDist*(nc-1))+1;
p(i) = patch(xd, yd, color(c,:));
end
set(gca,'Position',[0 0 1 1])
axis equal off
xlim(maxxy*[-1 1]*.75)
ylim(xlim())
hold off
end
rotate(p,[0 0 -1], 360/96)
end
Animation
Remix Tree