
#-----------------------------------------
# This slices an image with a 2:1 aspect
# ratio into a a form that can be cut 
# and glued into a globe
#-----------------------------------------

filter sinusoidal(int divs: 3-30 (8),
		  float pan: -180-180(0),
		  image in)    

#divs - Number of divisions to create.
#pan -  Panning left / right to align petals 
    py = -2;
    counter = 0;
    
    while (counter <= divs) do
      px = if (x>1-(2*counter/divs)-1/divs && x<=1-(2*counter/divs)+1/divs) 
           then (x-(1-(2*counter/divs)))/cos(y*pi)+1-(2*counter/divs)+W*pan/360
           end;
      if (x>1-(2*counter/divs)-1/divs && x<=1-(2*counter/divs)+1/divs) then
        if (px<=1-(2*counter/divs)+1/divs+W*pan/360 
            && px>=1-(2*counter/divs)-1/divs+W*pan/360)
           then py=y
           else py=py
           end;
      end;
      counter = counter + 1;
    end;

    #allow the x axis to loop around
    if px<-1 then px=px+2 end; 
    if px>1 then px=px-2 end;

    if py<-1 then
	grayColor(1)
    else 
	in(xy:[px,py])
    end
end