- /
-
Mathematical turbine
on 26 Oct 2024
- 27
- 124
- 0
- 1
- 631
Audio source: Candyland by Tobu
drawframe(1);
Write your drawframe function below
function drawframe(i)
%Generating the parametric surface on first iteration
persistent x y1 z1 denom
if i==1
aa=0.5;
wsqr = 1 - aa * aa;
w = sqrt(wsqr);
denom=@(u,v) aa*((w*cosh(aa*u)).^2+(aa*sin(w.*v)).^2);
x=@(u,v) -u+(2*wsqr*cosh(aa*u).*sinh(aa*u)./denom(u,v));
y1=@(u,v) 2*w*cosh(aa*u).*(-(w*cos(v).*cos(w*v))-(sin(v).*sin(w*v)))./denom(u,v);
z1=@(u,v) 2*w*cosh(aa*u).*(-(w*sin(v).*cos(w*v))+(cos(v).*sin(w*v)))./denom(u,v);
end
%Rotating the surface in each frame
ang=2*pi/97*i;
y=@(u,v) y1(u,v)*cos(ang)-z1(u,v)*sin(ang);
z=@(u,v) y1(u,v)*sin(ang)+z1(u,v)*cos(ang);
%Plotting
colormap("hsv")
fsurf(x,y,z,[-24,24,-24,24],'MeshDensity',70,'AmbientStrength',0.3,'DiffuseStrength',0.8)
camlight("headlight")
axis equal
xlim([-8,8])
ylim([-4,4])
zlim([-4,4])
view([-45,-25])
axis off
end