Thread Subject: Several surf's combined with hold on/off - lighting issues

Subject: Several surf's combined with hold on/off - lighting issues

From: Alexander

Date: 21 May, 2009 21:17:01

Message: 1 of 1

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
 

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com