title: Cubemap from panoramic horizontally wrappable image
body: <p><a href="https://i.stack.imgur.com/APd5R.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/APd5R.jpg" alt="Cubemap problem"></a>
  </p>
  
  <p>I'm trying to write an algorithm to generate the "ceiling panel" from a horiontally wrappable panoramic image like the one above. Images 1 to 4 are a straight cut out for the walls of the cube but the ceiling will be more complicated as I assume it needs to be composited from parts 5a to 5d. Does anyone know the solution in pseudocode?</p>
  
  <p>my guess is that we need to iterate over the coordinates of the ceiling tile
  i.e.</p>
  
  <pre><code>for y=0 to height
  for x=0 to width
       colorofsomecoordinateonoriginalimage = some function (poloar coords?)
       set pixel(x,y) = colorofsomecoordinateonoriginalimage
  next
  next
  </code></pre>