Advertisement
Guest User

cube_plotter

a guest
May 13th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clf
  2. %set limits and select view
  3. ax = axes('XLim', [-10 200], 'YLim', [-10 120], 'ZLim', [-10 120]);
  4. view(3);
  5. grid on;
  6. axis equal
  7.  
  8. h = cube([10 10 10], [5 5 5], 60);
  9.  
  10. %create group object and parent surfaces
  11. t = hgtransform('Parent', ax);
  12. set(h, 'Parent', t)
  13.  
  14. % Set the renderer to OpenGL and update the display
  15. set(gcf, 'Renderer','opengl')
  16.  
  17. drawnow
  18.  
  19. x_loc = linspace(1,200);  
  20. y_loc =  100 - ( (x_loc-100).^2)./(4*25);
  21. z_loc =  100 - ( (x_loc-100).^2)./(4*25);
  22. x_rot = sin(x_loc.*(pi / 180));
  23.  
  24.  
  25.  
  26. for i = 1:numel(x_loc)
  27.     trans = makehgtform('translate',[x_loc(i), y_loc(i), z_loc(i)]);
  28.     rotx  = makehgtform('zrotate',x_rot(i));
  29.     set(t, 'Matrix', trans*rotx);
  30.     pause (1/20)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement