Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

edit:Polygon inside a polygon

%To view plots after 'plot' (and other plot-producing commands) this command must follow: 'print -dpng some_unique_plot_name.png;'
%It exports current plot to png image which then is sent to your browser
%GNU Octave 4.2.2

n = 5;

a = 0.86;

k = 0:n-1;

x = cos(3*pi/2+pi/n+2*pi*k/n);

y = sin(3*pi/2+pi/n+2*pi*k/n);

k1 = 1:n;

k1(n+1) = 1;

function [x1,y1] = f(x,y,n,k1,a)

   for  i = 1:n 
   
   x1(i) = (x(k1(i+1))-x(k1(i)))*a + x(k1(i));
   
   y1(i) = (y(k1(i+1))-y(k1(i)))*a + y(k1(i)); 
   
   end 

end

hold on

for i = 1:30
   
   plot(x,y,"Linewidth",2,"Color",'b');
   
   plot([x(n),x(1)],[y(n),y(1)],"Linewidth",2,"Color",'b');

  [x1,y1] = f(x,y,n,k1,a);
  
  x = x1;
  
  y = y1;

end

axis off

print -dpng saif.png;
 run  | edit  | history  | help 0