• Remix
  • Share
  • New Entry

on 28 Nov 2023
  • 12
  • 56
  • 0
  • 2
  • 1944
drawframe(1);
Write your drawframe function below
function drawframe(f)
% more geology
% yippee!!
% the long-awaited (by me) prequel to Quartz Through the Microscope!!
% petrography is the study of rocks in thin section: 35 µm thick slices of rock viewed through a special microscope.
% a rock's appearance in thin section under a variety of lighting
% conditions gives insight into its mineral composition, grain size, history, etc.
% calcite (CaCO3) is an important sedimentary mineral that looks also pretty
% cool in thin section! here's a video of the real thing: https://www.youtube.com/watch?v=IvnvTFWGjV8
% HUGE!!!! thanks to Vinay Ramesh for helping me in getting this code
% to publish!!! i was having major network issues but the matlab staff
% is awesome <3
% the poor man's set(gcf): because i can't quite figure it out
plot(0,0,'.k', 'MarkerSize', 1100)
hold on
plot(0,0,'.', 'MarkerSize', 700, 'Color', [0.95 0.95 0.95])
set(gca,'Position',[0 0 1 1]) % Enlarge axes
xlim([-0.75 0.75]); ylim([-0.75 0.75]);
hold on
th = f*150/48;
% make our calcite crystal
xlx = [-0.29, -0.34, 0, 0.29, 0.34, 0]; xly = [-0.35 0.35 0.55 0.35 -0.35 -0.55];
rt = [cosd(th) -sind(th); sind(th) cosd(th)]; % rotate the slide
xl = [xlx; xly]'*rt;
% extinction: 1 wavelength = 90º
col = 0.9*abs(sind(th*2))*[1 1 1]+0.05;
patch(xl(:,1), xl(:,2), col)
hold on
% make the lines; these are the long ones
l1y = [-0.45:0.01:0.45]; x1 = ones(size(l1y));
l1x = 0*x1; l1 = [l1x; l1y]'*rt;
l1col = getCols(l1x, th, 43);
l2x = l1x+0.2*x1; l2y = 0.7*l1y; l2 = [l2x; l2y]'*rt;
l2col = getCols(l2x, th, 13);
l3x = l1x-0.2*x1; l3y = 0.7*l1y; l3 = [l3x; l3y]'*rt;
l3col = getCols(l3x, th, 1);
l4x = l1x-0.1*x1; l4y = 0.8*l1y; l4 = [l4x; l4y]'*rt;
l4col = getCols(l4x, th, 72);
l5x = l1x+0.1*x1; l5y = 0.8*l1y; l5 = [l5x; l5y]'*rt;
l5col = getCols(l5x, th, 32);
for i = 1:length(l1x)
plot(l1(i,1), l1(i,2), '.', 'Color', l1col(i,:), 'MarkerSize', 4)
hold on
plot(l2(i,1), l2(i,2), '.', 'Color', l2col(i,:), 'MarkerSize', 4)
hold on
plot(l3(i,1), l3(i,2), '.', 'Color', l3col(i,:), 'MarkerSize', 4)
hold on
plot(l4(i,1), l4(i,2), '.', 'Color', l4col(i,:), 'MarkerSize', 4)
hold on
plot(l5(i,1), l5(i,2), '.', 'Color', l5col(i,:), 'MarkerSize', 4)
hold on
end
% these are the diagonal lines
d1x = [-0.15:0.002:0.15]; dx = ones(size(d1x));
d1y = tand(60)*d1x; d2y = d1y+0.1*dx; d3y = d1y-0.1*dx;
d1 = [d1x; d1y]'*rt; d1col = getCols(d1x, th, 3);
d2 = [d1x-(0.1*dx); d2y]'*rt; d2col = getCols(d1x, th, 43);
d3 = [d1x+(0.1*dx); d3y]'*rt; d3col = getCols(d1x, th, 20);
for i = 1:length(d1x)
plot(d1(i,1), d1(i,2), '.', 'Color', d1col(i,:), 'MarkerSize', 3)
hold on
plot(d2(i,1), d2(i,2), '.', 'Color', d2col(i,:), 'MarkerSize', 3)
hold on
plot(d3(i,1), d3(i,2), '.', 'Color', d3col(i,:), 'MarkerSize', 3)
hold on
end
hold off
end
function lineCol = getCols(x, th, st)
xlen = length(x);
cmapl = double(floor(xlen*1.25));
cmap = colormap(hsv(cmapl));
lineCol = zeros(xlen, 3);
for i = 1:xlen
idx = mod(st+i, cmapl)+1;
lineCol(i,:) = cmap(idx,:)*abs(cosd(th*2));
end
end
Animation
Remix Tree