• Remix
  • Share
  • New Entry

on 29 Nov 2023
  • 13
  • 90
  • 0
  • 3
  • 1794
drawframe(25);
Write your drawframe function below
function drawframe(f)
% more geology >:D
close
% draw stuff
% i had to recenter these bc i drew this out on paper first and forgot
% to set my coordinate system in a way that makes sense haha :')
% hammer head
hm=[21 27 27 22 17 15 15 16 12 13 13 11 6 1 1 7 11 17;
38 36 35 36 36 34 25 23 23 25 34 36 36 35 36 38 39 39];
% want to rotate around the point that's the middle of the handle
hm=hm-([14;15].*ones(size(hm)));
% hammer handle
hd=[16 16 17 16 12 11 12 12;
23 7 2 1 1 2 7 23];
% want to rotate around the point that's the middle of the handle
hd=hd-([14;15].*ones(size(hd)));
% left half of the rock
rl=[16 14 16 15 16 15 16 13 8 5 3 2 1 2 5 7 9 10 11 14;
18 14 11 8 5 3 2 2 3 4 5 8 10 13 15 15 16 16 17 17];
% want to rotate around the point that's the bottom right
rl=rl-([16;2].*ones(size(rl)));
% right half of the rock
rr=[16 19 22 24 28 29 29 30 30 29 26 24 22 19 16 15 16 15 16 14;
18 18 17 17 15 12 11 10 9 8 7 5 4 3 2 3 5 8 11 14];
% want to rotate around the point that's the bottom left
rr=rr-([16;2].*ones(size(rr)));
% the crack
% i pre-centered this HA
cr = [ 0 -2 0 -1 0 -1 0;
16 12 9 6 3 1 0];
% colors
hdcol=[122, 94, 53]/256; % handle
hmcol=[0.7 0.7 0.8]; % hammer head
rcol=[94, 89, 80]/256; % rock
if f<=12 % swing the hammer
th=f*90/12;
hm=(hm'*rotate(th));
mv=([10 0].*ones(size(hm)));
hm=hm-mv;
hd=(hd'*rotate(th));
mv=([10 0].*ones(size(hd)));
hd=hd-mv;
rl=rl-([-11;29].*ones(size(rl)));
rr=rr-([-11;29].*ones(size(rr)));
patch(hm(:,1),hm(:,2),hmcol)
patch(hd(:,1),hd(:,2),hdcol)
patch(rl(1,:),rl(2,:),rcol,'EdgeColor',rcol)
patch(rr(1,:),rr(2,:),rcol,'EdgeColor',rcol)
end
if f>12 % now the rock changes
hm=(hm'*rotate(90));
mv=([10 0].*ones(size(hm)));
hm=hm-mv;
hd=(hd'*rotate(90));
mv=([10 0].*ones(size(hd)));
hd=hd-mv;
patch(hm(:,1),hm(:,2),hmcol)
patch(hd(:,1),hd(:,2),hdcol)
if f<25 % crack forms
rl=rl-([-11;29].*ones(size(rl)));
rr=rr-([-11;29].*ones(size(rr)));
patch(rl(1,:),rl(2,:),rcol,'EdgeColor',rcol)
patch(rr(1,:),rr(2,:),rcol,'EdgeColor',rcol)
i = floor((f-10)/2)
cr=cr-([-11;29].*ones(size(cr)))
hold on
plot(cr(1,1:i),cr(2,1:i),'-k')
hold on
end
if f>=25 % rock breaks
th=(f-24)*0.9;
rl=(rl'*rotate(-0.75*th));
mv=([-11 29].*ones(size(rl)));
rl=rl-mv;
rr=(rr'*rotate(1.2*th));
mv=([-11 29].*ones(size(rr)));
rr=rr-mv;
patch(rl(:,1),rl(:,2),rcol,'EdgeColor',rcol)
patch(rr(:,1),rr(:,2),rcol,'EdgeColor',rcol)
end
end
xlim([-30 30]);
ylim([-35 25]);
xticks([]); yticks([]); xticklabels([]); yticklabels([]);
end
function rt = rotate(th)
rt=[cosd(th) -sind(th); sind(th) cosd(th)];
end
Animation
Remix Tree