<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/251922</link>
    <title>MATLAB Central Newsreader - Several surf's combined with hold on/off - lighting issues</title>
    <description>Feed for thread: Several surf's combined with hold on/off - lighting issues</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 21 May 2009 21:17:01 -0400</pubDate>
      <title>Several surf's combined with hold on/off - lighting issues</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/251922#651536</link>
      <author>Alexander </author>
      <description>Hello, &lt;br&gt;
&lt;br&gt;
I am writing a program in which I create a 3D plot of an object consisting of several single parts. Here's an image: &lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://img4.abload.de/img/spin_model0aa4.png&quot;&gt;http://img4.abload.de/img/spin_model0aa4.png&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
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 &quot;camlight left&quot;, the rings do not cast any shadows on the flat plate-like object. &lt;br&gt;
&lt;br&gt;
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?&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
If no: how then? &lt;br&gt;
&lt;br&gt;
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):&lt;br&gt;
&lt;br&gt;
Wait, let me say regards first:&lt;br&gt;
&lt;br&gt;
Curious to read your responses! &lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
Alexander&lt;br&gt;
&lt;br&gt;
% --------------------minimal program-----------------&lt;br&gt;
&lt;br&gt;
% Suppose I have tow simple objects, a sphere and a cylinder. They are to&lt;br&gt;
% be plotted with surf&lt;br&gt;
&lt;br&gt;
[X1,Y1,Z1]=cylinder;&lt;br&gt;
[X2,Y2,Z2]=sphere;&lt;br&gt;
&lt;br&gt;
% I can not plot them BOTH, at least I don't know how. So I plot one of&lt;br&gt;
% them first, let's say the cylinder.&lt;br&gt;
&lt;br&gt;
H=surf(X1,Y1,Z1);&lt;br&gt;
axis square;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
% Optional: I might do some shading stuff here, like in the image attatched above:&lt;br&gt;
&lt;br&gt;
shading interp;&lt;br&gt;
colormap copper;&lt;br&gt;
FaceColor='copper';&lt;br&gt;
EdgeColor='none';&lt;br&gt;
camlight left;&lt;br&gt;
lighting phong;&lt;br&gt;
&lt;br&gt;
% Now I use hold on/off to add another surf plot&lt;br&gt;
&lt;br&gt;
hold on;&lt;br&gt;
G=surf (X2,Y2,Z2);&lt;br&gt;
hold off;&lt;br&gt;
&lt;br&gt;
% Now, both of them are contained in the current figure. I also kept their&lt;br&gt;
% handles, so I can do with them whatever I need to do, I might for example&lt;br&gt;
% rotate and translate them, scale them up etc.&lt;br&gt;
&lt;br&gt;
% Here's just some translation&lt;br&gt;
&lt;br&gt;
&amp;nbsp;set(H,'XData',X1+1,'YData',Y1+1,'ZData',Z1+1);&lt;br&gt;
&amp;nbsp;set(G,'XData',X2+1,'YData',Y2+1,'ZData',Z2+1);&lt;br&gt;
&amp;nbsp;drawnow&lt;br&gt;
&amp;nbsp;</description>
    </item>
  </channel>
</rss>

