from
Furniture
by Matt Fetterman
This Matlab program creates an image of a 3D end table.
|
| Furniture.m |
% Matlab Furniture
% Matt Fetterman mattinjersey@yahoo.com
% This function creates a 2D surface that looks like a pretty cool table.
MaxCount=100;
xLength=MaxCount;yLength=MaxCount;
midLevel=round(MaxCount/2);
% This part creates a quadratic surface that can be seen as the inside
% of the table.
for xstar=1:MaxCount,
for ystar=1:MaxCount,
A1matrix(ystar,xstar)=-pi^2*( ((xstar-midLevel)/xLength)^2 + ((ystar-midLevel)/yLength)^2 );
end;
end;
% then this part sets the outer edge of the table equal to zero,
% creating the frame seen at the top of the table as well as defining the
% edge of the quadratic function above.
StarLength=30;
windowstar=ones(MaxCount,MaxCount);
for xstar=1:MaxCount,
for ystar=1:MaxCount,
if abs(xstar-midLevel)>StarLength | abs(ystar-midLevel)>StarLength,
windowstar(xstar,ystar)=0;
end;
end;
end;
% multiply the quadratic inside by the outer frame to get the endtable.
Zmatrix=A1matrix.*windowstar;
% plot the mesh.
Aaxis=[1:100];
mesh(Aaxis,Aaxis,Zmatrix);
axis off;
|
|
Contact us at files@mathworks.com