|
Hello,
I am writing a program in which I create a 3D plot of an object consisting of several single parts. Here's an image:
http://img4.abload.de/img/spin_model0aa4.png
I am using surf. In order to plot the different objects, I plotted the first one with surf (keeping a handle), then plotted the other ones in the very same way, just with hold on/off. The result (like you see in the picture) is that something's wrong with the lighting. Even though I use phong shading and a "camlight left", the rings do not cast any shadows on the flat plate-like object.
How might I achieve that? Possibly by plotting all of the objects (rings and plate-like thing) into _one_ surf-command without doing the hold on/off process?
If yes: How can I plot all of the objects into one surf command? The plate is done with cylinder, the tori with a parametric plot? And even if I was able to put all of them into one surf plot somehow, I would require to keep track of where in those huge X, Y, Z matrices which object (ring etc.) is, because I need to rotate them.
If no: how then?
If you are interested in how exactly I do what with the hold on/off command, here's a commented minimal program (that acutally works):
Wait, let me say regards first:
Curious to read your responses!
Regards
Alexander
% --------------------minimal program-----------------
% Suppose I have tow simple objects, a sphere and a cylinder. They are to
% be plotted with surf
[X1,Y1,Z1]=cylinder;
[X2,Y2,Z2]=sphere;
% I can not plot them BOTH, at least I don't know how. So I plot one of
% them first, let's say the cylinder.
H=surf(X1,Y1,Z1);
axis square;
% Optional: I might do some shading stuff here, like in the image attatched above:
shading interp;
colormap copper;
FaceColor='copper';
EdgeColor='none';
camlight left;
lighting phong;
% Now I use hold on/off to add another surf plot
hold on;
G=surf (X2,Y2,Z2);
hold off;
% Now, both of them are contained in the current figure. I also kept their
% handles, so I can do with them whatever I need to do, I might for example
% rotate and translate them, scale them up etc.
% Here's just some translation
set(H,'XData',X1+1,'YData',Y1+1,'ZData',Z1+1);
set(G,'XData',X2+1,'YData',Y2+1,'ZData',Z2+1);
drawnow
|