• Remix
  • Share
  • New Entry

  • Sarah Preston

  • /
  • Quartz Through the Microscope but it's approximately 12% more realistic & at a lower magnification

on 29 Nov 2023
  • 10
  • 9
  • 0
  • 0
  • 849
drawframe(1);
Write your drawframe function below
function drawframe(f)
% this is a remake of https://www.mathworks.com/matlabcentral/communitycontests/contests/6/entries/14997
% but this one is a bit more realistic and is at a lower magnification!
rng(5)
hex = @(cx, cy, r) [cx + r * sind(30:60:359);
cy + r * cosd(30:60:359)]; % very slightly modified from the function sudharsana iyengar used in his abstract:tiles entry!
xls = [];
for i = -5:5
for j = -5:5
%h = hex(i*2, j*2*sqrt(2), sqrt(2))
xls = [xls; hex(i*3, j*sqrt(3), 1)];
xls = [xls; hex(i*3+1.5, j*sqrt(3)+sqrt(3)/2, 1)];
end
end
th = 150*f/48;
rt = [cosd(th) -sind(th); sind(th) cosd(th)];
c = rand(1,max(size(xls)));
for k = 1:2:max(size(xls))
col = 0.95*abs(sind(th*2+(c(k)*180)))*[1 1 1]+0.01;
xl = [0.8*xls(k,:); xls(k+1,:)]'*rt;
patch(xl(:,1), xl(:,2), col)
end
px = zeros(1,14996);
py = zeros(1,14996);
idx = 1;
for i = 0:0.1:10
for j = 0:0.1:10
if i^2 + j^2 > 49
px(idx) = i; py(idx) = j;
px(idx+1) = i; py(idx+1) = -j;
px(idx+2) = -i; py(idx+2) = -j;
px(idx+3) = -i; py(idx+3) = j;
idx = idx+4;
end
end
end
% set up the background
hold on
plot(px, py, '.k')
hold on
plot([0 0], [-10 10], '-k', 'LineWidth', 0.1)
hold on
plot([-10 10], [0 0], '-k', 'LineWidth', 0.1)
xticks([]); yticks([]); xlabel([]); ylabel([]);
xlim([-8 8]); ylim([-8 8])
end
Animation
Remix Tree