Advertisement
Guest User

Untitled

a guest
Nov 16th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.92 KB | None | 0 0
  1. Po = [1 2 2 1;1 1 2 2;1 1 1 1];
  2. hold on;
  3.  
  4. %plot(Po(1,1), Po(2,1));
  5. %plot(Po(1,2), Po(2,2));
  6. %plot(Po(1,3), Po(2,3));
  7. %plot(Po(1,4), Po(2,4));
  8.  
  9. line([Po(1,1), Po(2,1)],[Po(1,2), Po(2,2)]);
  10. line([Po(1,2), Po(2,2)],[Po(1,3), Po(2,3)]);
  11. line([Po(1,3), Po(2,3)],[Po(1,4), Po(2,4)]);
  12. line([Po(1,4), Po(2,4)],[Po(1,1), Po(2,1)]);
  13.  
  14. Xcentro = (max(Po(1,:)) + min(Po(1,:)))/2;
  15. Ycentro = (max(Po(2,:)) + min(Po(2,:)))/2;
  16. ang = 5;
  17. figure;
  18. while (ang<5000)
  19.   T1 = [1 0 -Xcentro;0 1 -Ycentro;0 0 1];
  20.   T2 = [cos(ang) -sin(ang) 0;sin(ang) cos(ang) 0;0 0 1];
  21.   T3 = [1 0 Xcentro;0 1 Ycentro;0 0 1];
  22.   Pt = (T3 * T2 * T1) * Po;
  23.   H(1) = line([Pt(1,1), Pt(2,1)],[Pt(1,2), Pt(2,2)]);
  24.   H(2) = line([Pt(1,2), Pt(2,2)],[Pt(1,3), Pt(2,3)]);
  25.   H(3) = line([Pt(1,3), Pt(2,3)],[Pt(1,4), Pt(2,4)]);
  26.   H(4) = line([Pt(1,4), Pt(2,4)],[Pt(1,1), Pt(2,1)]);
  27.   drawnow;
  28.   pause(0.01);
  29.   ang = ang + 5;
  30.   delete(H(:));
  31. endwhile
  32.  
  33. hold off;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement