- /
-
Arrival of a Train for Happy Sheep!
on 3 Nov 2024
- 49
- 401
- 0
- 4
- 1966
Cite your audio source here (if applicable): the train in the desert somewhere in Uzbekistan (self-made audio).
Happy Sheep goes travelling around the world with her friend MATLAMB!!!
The movie is inspired by the the following films:
Auguste and Louis Lumière, L'Arrivée d'un train en gare de La Ciotat, 1896:
and
Georges Méliès, Arrivée d'un train (gare de Joinville), 1896:
A short Happy Sheep's biography is below:
and
https://www.mathworks.com/matlabcentral/discussions/tips/847476-how-to-draw-a-happy-sheep-in-matlab .
After returning from her last trip
and
Happy Sheep decided to start a new fascinating adventure and called MATLAMB to join her:
A train for Happy Sheep is arriving! MATLAMB is already inside this train in the movie!
drawframe(48);
Write your drawframe function below
function drawframe(f)
% Arrival of a Train for Happy Sheep!
% By Victoria A. Sablina
% Handles
s=@sin;
c=@cos;
% Ellipse + Polar Rose
F=@(t,a,f) a(4)*f(t)+a(1)*s(a(2)*t).*f(t)+a(3);
% Clearing the current frame
clf;
axis([-250 70 -170 70],'equal','off','manual');
% A Train on the Railway!
% Scaling coefficients for moving the train
K=min(1,f/48);
% Parameters for drawing the lines of the train
% The rails are fixed on the ground!
C=K*reshape([-240/K -175 -100/K -72.9 -160/K 0 -100/K 0 -210 -140 -72.9 -72.9 -140 -140 -72.9 -58.3 -210 -210 -72.9 -58.3 -140 -210 -58.3 -58.3 -140 0 -72.9 0 -180 -170 -14.3 -14.3 -180 -170 15 15 -170 -170 -14.3 15 -180 -180 -14.3 15 -20 -20 -10.4 5.2 -40 -40 -20.8 10.4 -80 -80 -41.7 20.9 -100 -100 -41.6 26 -100 -20 26 5.2 -140 -100 -58.3 -41.7 -161 -125.2 -53.3 -41.7 -125.2 -100 -41.7 -41.7 -175 -125.5 -14.3 -10.3 -150 -100 26 26 -150 -150 -12.3 26 -210 -189.4 -58.3 -52.9 -95 -85 15 13.4 -95 -85 -15 -13.4 -95 -95 -15 15 -85 -85 -13.4 13.4],2,2,27);
% Angles for drawing circles and their arcs
T=[0 -1.6 -2.7 -2.8;7 1.7 .55 -.3];
for j=1:7
m=max(1,j-3);
Q{j}=T(1,m):.1:T(2,m);
end
% Parameters for drawing the round parts of the train
E=K*[zeros(2,2,7);reshape([-175 22 -36.3 22 -175 7.3 -36.3 7.3 -202.7 7.3 -65.6 7.3 -147.3 7.3 -65.6 7.3 -125.2 15.7 -26 15.7 -129 11 -67.7 11 -196 11 -69.4 11],2,2,7)];
% Painting the train
hold on;
% Lines
for j=1:27
plot(C(:,1,j),C(:,2,j),'LineWidth',5,'Color','k');
end
% Circles and their arcs
for j=1:7
plot(F(Q{j},E(:,1,j),c),F(Q{j},E(:,2,j),s),'LineWidth',5,'Color','k');
end
% Happy Sheep on Vacation!
% Shifting coefficients for moving the sheep
L=max(1,f-48);
d=abs(L-24.5)/100;
% Angles for drawing the sheep
t=0:.1:7;
% Parameters for drawing the sheep
% Head (1:2)
% Eyes (3:6)
% Hoofs (7:14)
% Body (15:16)
% Crown (17:18)
% Tail (19:20)
% Smile (21:22)
Z=zeros(1,6);
O=Z+1;
B=[.1*O;.5*O];
G=-13;
P=[Z Z 1 1 O 0 -3;O O 0 0 8 8 12 12 4 3 1 1;-15 2 G 3 -17 3 -3 G 0 G 9 G 12 G -15 10 4 3 20 7 -15 7.5;5 7 B(:)' 6 4 14 9 3 3 5 7];
% The sheep is waiting for a train and then walking
if f>48
P(3,1:2:end)=P(3,1:2:end)-L/4;
end
% Shifting the sheep
P(3,1:2:end)=P(3,1:2:end)+10;
P(3,2:2:end)=P(3,2:2:end)-30;
% Scaling the sheep
P([1 3 4],:)=2*P([1 3 4],:);
% Tail waving
P(2,20)=2.8+d;
e=2*abs(mod(L,24)-12.25)^2/100;
j=[10*d 0 10*d 0];
% Walking
if L<25
P(3,[7:8 11:12])=P(3,[7:8 11:12])+2*[10*d 3-e 10*d 3-e];
P(3,[9:10 13:14])=P(3,[9:10 13:14])-2*j;
else
P(3,[7:8 11:12])=P(3,[7:8 11:12])+2*j;
P(3,[9:10 13:14])=P(3,[9:10 13:14])-2*[10*d e-3 10*d e-3];
end
% Painting the sheep
for i=[2:8 10]
plot(F(t,P(:,2*i-1),c),F(t,P(:,2*i),s),'LineWidth',3,'Color','b');
end
% Crown
t=2.5:.1:7.2;
plot(F(t,P(:,1),c),F(t,P(:,2),s),'LineWidth',3,'Color','b');
% Body
t=-2.9:.1:2.7;
plot(F(t,P(:,17),c),F(t,P(:,18),s),'LineWidth',3,'Color','b');
% Smiling
t=(4.3-d):.1:(5.2+d);
plot(F(t,P(:,21),c),F(t,P(:,22),s),'LineWidth',3,'Color','b');
end