GLE Library: polarplot.gle


! Subroutines to create polar plots (r = f(theta))

sub polar fct$ t1 t2 tstep color$ fill$ lwidth
   default tstep  0.025
   default color  black
   default fill   clear
   default lwidth 0.02
   t = t1
   r = eval(fct$)
   gsave
   set color color$ lwidth lwidth
   begin path stroke fill fill$
      amove xg(r*cos(t)) yg(r*sin(t))
      for t = t1+tstep to t2 step tstep
          r = eval(fct$)
          aline xg(r*cos(t)) yg(r*sin(t))
      next t
      closepath
   end path
   grestore
end sub

sub polar_grid radius rings sectors color$
  default radius  1.0
  default rings   4
  default sectors 8
	default color   gray10
	gsave
	set color color$
	for ring = 1 to rings
	   amove xg(0) yg(0)
	   circle xg(radius/rings*ring)-xg(0)
	next ring
	for sector = 1 to sectors	   
	   local theta = 2*pi/sectors*(sector-1)
	   amove xg(0) yg(0)	   
	   aline xg(radius*cos(theta)) yg(radius*sin(theta))
	next sector
	grestore
end sub