• Remix
  • Share
  • New Entry

on 23 Nov 2023
  • 5
  • 9
  • 0
  • 0
  • 877
drawframe(1);
Write your drawframe function below
function drawframe(f)
narginchk(0,2);
[cax,args,nargs] = axescheck(5);
n = 40;theta = (-n:2:n)/n*pi;
phi = (0:1:n)'/n*pi/2;cosphi = cos(phi); cosphi(n+1) = 0;
sintheta = sin(theta); sintheta(1) = 0; sintheta(n+1) = 0;
x = cosphi*cos(theta);y = cosphi*sintheta;
z = sin(phi)*ones(1,n+1);
figure('Color', [0.53, 0.81, 0.98]);
if nargout == 0
cax = newplot(cax);
surf(x,y,z-0.27*f,'parent',cax)
shading interp
else
xx = x; yy = y; zz = z;
end
hold on
a = -pi : pi/2 : pi;
ph1 = pi/4;
x1 = [cos(a+ph1); cos(a+ph1)]/cos(ph1);
y1 = [sin(a+ph1); sin(a+ph1)]/sin(ph1);
z1 = [-ones(size(a)); ones(size(a))];
surf(0.5*x1, 0.5*y1, (0.5*z1)-2-0.27*f, 'FaceColor','g')
colormap(hsv)
ground_color = 0.6 * [0.5, 0.2, 0];
[x, y] = meshgrid(-2:0.1:2, -2:0.1:2);
brown = [0.5, 0.2, 0];
green = [0, 0.5, 0];
mixed_color = 0.5 * brown + 0.5 * green;
surf(x, y, ones(size(x))*(-10), 'FaceColor', mixed_color, 'EdgeColor', 'none');
axis([-2 2 -2 2 -10 2])
axis off
hold off
end
Animation
Remix Tree