• Remix
  • Share
  • New Entry

on 6 Nov 2023
  • 10
  • 22
  • 0
  • 0
  • 880
drawframe(1);
Write your drawframe function below
function drawframe(f)
set(gcf,'color','k')
ax = newplot;
set(ax,'position',[0 0 1 1], 'visible', 'off');
p = patch(ax,'Vertices',[],'Faces',[], ...
'FaceC', 'interp', 'EdgeC', 'n','FaceL', 'g', ...
'FaceAlpha', .8);
material(ax,[ .6 .9 .3 2 .5 ])
camlight(ax)
daspect(ax,[1 1 1])
axis(ax, [ 0 30 0 30 0 20 ])
xlim(ax,[0 30])
q = (.33333/47)*(f-1);
os = [ 0; .33; .66 ];
[cx, cy] = pol2cart((q+os)*pi, sinpi(3*(q+os)));
c = [ cx cy [0;0;0] ] * 10;
cpos = [15 15 10]+c;
nx=30;
ny=30;
nz=20;
a=.05;
b=1;
[y,x,z]=ndgrid(1:ny,1:nx,1:nz);
B=zeros(ny,nx,nz);
for i=1:size(cpos,1)
B=B+b*exp(-a*((cpos(i,1)-x).^2 + (cpos(i,2)-y).^2 + (cpos(i,3)-z).^2));
end
S=isosurface(B,.8);
d=@(vrt,pos)1-rescale(hypot(vrt(:,1)-pos(1),vrt(:,2)-pos(2)), 0, 1, 'InputMax', 8);
red = d(S.vertices,cpos(1,:));
green = d(S.vertices,cpos(2,:));
blue = d(S.vertices,cpos(3,:));
rgb = max([ red, green, blue ], .2);
hsv = rgb2hsv(rgb);
hsv(:,2) = 1;
S.facevertexcdata = hsv2rgb(hsv);
set(p,S);
end
Animation
Remix Tree