function lego(w,r,n)
%%
clf
s=0;
for i=1:n
s=s+w/2;
cubeplot(0,0,s,w)
s=s+w/2;
w=w*r;
end
view(45,30)
%%
function cubeplot(a,b,c,l)
hold on
[x,y,z] = meshgrid([-(l/2)+a,(l/2)+a],[-(l/2)+b,(l/2)+b],l/2+c);
surf(x,y,z)
[x,y,z] = meshgrid([-(l/2)+a,(l/2)+a],[-(l/2)+b,(l/2)+b],-(l/2)+c);
surf(x,y,z)
[z,y,x] = meshgrid([-(l/2)+c,(l/2)+c],[-(l/2)+b,(l/2)+b],l/2+a);
surf(x,y,z)
[z,y,x] = meshgrid([-(l/2)+c,(l/2)+c],[-(l/2)+b,(l/2)+b],-(l/2)+a);
surf(x,y,z)
[x,z,y] = meshgrid([-(l/2)+a,(l/2)+a],[-(l/2)+c,(l/2)+c],l/2+b);
surf(x,y,z)
[x,z,y] = meshgrid([-(l/2)+a,(l/2)+a],[-(l/2)+c,(l/2)+c],-(l/2)+b);
surf(x,y,z)end
0 comments:
Post a Comment