Note that there are some explanatory texts on larger screens.

plurals
  1. POMaking movie: position of camera & multiple scenes
    primarykey
    data
    text
    <p>This is an example code that represents what I need to do:</p> <pre><code>ang=0:0.01:2*pi; r = 1; xp=r*cos(ang); yp=r*sin(ang); frequency = 1/0.016; % real frequency datalength = length(ang); % n° of points scale = 10; % resampling nFrames = floor(datalength/scale); % figure figure() set(gcf, 'Color','white') hold on axis equal set(gca, 'nextplot','replacechildren', 'Visible','off'); % ? % preallocate mov(1:nFrames) = struct('cdata',[], 'colormap',[]); % create movie for k = 1:nFrames axes(gca); cla; hold on plot3(xp,yp,zeros(size(xp))); plot3(1,0,0,'kx'); % Update Target for j = 1:scale id = (k-1)*scale + j; CurTar = ang(id); PsiTar = CurTar + pi*0.5; end % Plot obj plot3(2*xp(id),2*yp(id),0,'k.','LineWidth',4) % Plot Target plot3(xp(id),yp(id),0,'r.','LineWidth',3) a = -PsiTar - 0.75*pi; % Set Camera xc = xp(id) - sin(a); yc = yp(id) - cos(a); zc = 0.5; campos([xc,yc,zc]) camtarget([xp(id),yp(id),0]) mov(k) = getframe(gcf); end close(gcf) movie2avi(mov, 'mymovie', 'fps', round(frequency/scale)); </code></pre> <p>I have the following problems/questions with it:</p> <ul> <li><p>I would like to plot the circle once, and not every loop. I tried to place it before the <code>for</code> loop, but at that point is not maintained at each iteration, unless I comment out the <code>axes(gca); cla;</code> line, but this has a significant other drawback: everything is maintained, not only the circle.</p></li> <li><p>I would like to have the same scene seen from multiple angles. I know how to do subplots and I would know how to plot the same thing multiple times and simply set the camera differently, is there a way of plotting once and having multiple projections?</p></li> <li><p>I have a problem with the position of the camera. You see that I have that <code>sin</code> and <code>cos</code> in the definition of <code>xc</code> ynd <code>yc</code>. In this example everything is fine, but the same code in my full script leads to the error :</p> <pre><code>??? Error using ==&gt; set Value must be a 3 element numeric vector Error in ==&gt; campos at 50 set(ax,'cameraposition',val); </code></pre> <p>how may I get rid of it? I have printed to screen all values and they are numerical, I have no idea what might be happening.</p></li> </ul> <p><strong>EDIT:</strong></p> <p>additional question</p> <p>If I plot the following</p> <pre><code>for k = 1:nFrames axes(gca); cla; hold on plot3(zeros(length(ang)),ang,zeros(length(ang)),'b') % Update Target for j = 1:scale id = (k-1)*scale + j; end % Plot obj plot3(0,2*yp(id),0,'k.','LineWidth',4) if k==1 view(0,0) camzoom(50) end camtarget([0,yp(id),0]) end close(gcf) </code></pre> <p>you can see that the camera is not aligned with the <code>y</code> axis, otherwise you would not see the blue line. Why is that? how is it possible to avoid it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload