- /
-
Voronoi Spheres
on 22 Nov 2023
- 12
- 14
- 0
- 1
- 375
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent n k m theta phi
if isempty(n)
n=64;
k=20;
m=randi(5,k,3);
theta = pi*(-n:2:n)/n;
phi = (pi/2)*(-n:2:n)'/n;
end
r=f/24;
for i=1:k
X = r*cos(phi)*cos(theta)+m(i,1);
Y = r*cos(phi)*sin(theta)+m(i,2);
Z = r*sin(phi)*ones(size(theta))+m(i,3);
surf(X,Y,Z,Y);
hold on;
end
plot3(-2,-2,-2);
plot3(7,7,7);
shading interp;
axis off equal;
colormap(parula);
lightangle(80,-40);
lightangle(-90,60);
view(-f,f);
hold off;
end