- /
-
Splashing water drop
on 20 Oct 2024
- 34
- 325
- 0
- 2
- 840
Cite your audio source here (if applicable):
drawframe(40);
Write your drawframe function below
function drawframe(i)
WStart=20; %Wave start
DStart=23; %Droplet start
[X,Y]=meshgrid(-4:0.1:4,-4:0.1:4);
alpha=pi*i/WStart; %Change phase angle to start with a concave surface
%Waves amplitude
if i<WStart
if i<WStart-15 %Before the sphere touches the surface
amp=0;
else %While the sphere is entering the water
amp=2*i^3/WStart^3;
end
ampExp=6;
else
if i<WStart+29 %Propagation of the wave
amp=2;
ampExp=6-(i-WStart)/8;
else %Wave amplitude decrease
amp=80/(i-19)-0.011*i;
ampExp=2+0.5*exp((WStart+29-i)/2);
end
end
%Water surface
Z=amp*sin(abs(X).^2+abs(Y).^2-alpha)./(abs(X).^ampExp+abs(Y).^ampExp+1);
surf(X,Y,Z,"FaceColor",'interp','LineStyle',':')
%Falling sphere
if i<WStart+40
if i<=7
Opacity=i/8;
else
Opacity=1;
end
[Sx,Sy,Sz]=sphere(20);
hold on
surf(Sx,Sy,Sz+2*(1-1.5*i/WStart),(Sz+2*(1-1.5*i/WStart))./2,"FaceAlpha",Opacity,"EdgeAlpha",Opacity)
hold off
end
%Droplets
if i>DStart
[Sx,Sy,Sz]=sphere(20);
r1=0.3;
r2=1.5*r1;
hold on
surf(r1*Sx,r1*Sy,r1*Sz+i/5-4,(r1*Sz+i/5-4)./2)
surf(r2*Sx,r2*Sy,r2*Sz+(45-i)/24*(i-31),(r2*Sz+(45-i)/24*(i-31))./2)
hold off
end
%Graphic config
axis equal
xlim([-4,4])
ylim([-4,4])
zlim([-1,5])
clim([-1,1])
view([-35,20])
set(gca, 'Projection','perspective')
axis off
end