Advertisement
dmkozyrev

Трехлепестковая роза

Dec 5th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.63 KB | None | 0 0
  1. function draw_roses(n)
  2.     color = ['r' 'b' 'm'];
  3.     T = 360/n;
  4.     t = 0; i = 0;
  5.     while t<360
  6.         t=t+T;
  7.         i=i+1; if (i > 3) i=1; end
  8.         rose(1, color(i), t);
  9.         pause(0.2);
  10.     end
  11. end
  12.  
  13. function rose(a, color, degree)
  14.     t=0;
  15.     p=Pero(a, 0);
  16.     p.set('lineColor', color);
  17.     while (t < 2*pi)
  18.         t=t+pi/60;
  19.         x=a*cos(t)*cos(3*t);
  20.         y=a*sin(t)*cos(3*t);
  21.         p.punct(x, y);
  22.     end
  23.     p.transform(@rotation, degree);
  24.     p.draw;  
  25. end
  26.  
  27. function [x2, y2]=rotation(x1, y1, degree)
  28.     t=degree*pi/180;
  29.     x2 = x1*cos(t) - y1*sin(t);
  30.     y2 = x1*sin(t) + y1*cos(t);
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement