Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. %the path.
  2. %Setup path
  3. s=0:.01:1;
  4. X=6*s.^2-5*s.^3;
  5. Y=6*s-12*s.^2+6*s.^3;
  6. plot(X,Y)
  7. hold all
  8.  
  9. %Setup drawing
  10. set(gca,'XLim',[-0.2 1.5],'YLim',[-0.2 1.5], 'Drawmode', 'fast', 'visible', 'on');
  11. axis square
  12. ball=line('color','r','Marker','o','MarkerSize',10,'LineWidth',2,'erase','xor','xdata',[],'ydata',[]);
  13. ball2=line('color','b','Marker','o','MarkerSize',10,'LineWidth',2,'erase','xor','xdata',[],'ydata',[]);
  14.  
  15. %Original Parameter
  16. t=.00:.05:20;
  17.  
  18. t2 = zeros(20,1);
  19. %Constant Speed
  20. for i=0:20
  21. t2(i+1)=newtarclen(i*.05,.001);
  22. end
  23.  
  24.  
  25. a=6*t.^2-5*t.^3;
  26. b=6*t-12*t.^2+6*t.^3;
  27.  
  28. c=6*t2.^2-5*t2.^3;
  29. d=6*t2-12*t2.^2+6*t2.^3;
  30.  
  31. for i = 1:21
  32. set(ball,'xdata',a(i),'ydata',b(i));
  33. set(ball2,'xdata',c(i),'ydata',d(i));
  34. drawnow;
  35. pause(0.01);
  36. frame = getframe(1);
  37. im = frame2im(frame);
  38. [imind,cm] = rgb2ind(im,256);
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement