I've had a go at trying to figure this one out, but i've hit a snag. The way I see it is that there are two coordinate sets.
The first is texture space and the second is the Polar space. I have no problems converting texture space to Polar space, but this is not the way to do it. It fragmented and incorrect. The way to do it is to convert Polar space into Texture space, this way you dont get any fragmentation. Unfortunately I lack the mathematical ability to figure out how to reverse the process so I can convert Polar to Texture space.
Heres how to convert Texture to Polar space: -
Function Polar()
Local xScale# = 0.675
Local yScale# = 0.5
Local cx#
; Texture Image size
Local iWidth = ImageWidth( TextureImage )
Local iHeight = ImageHeight( TextureImage )
; Texture Image size halved
Local half_iWidth = Floor( iWidth / 2 )
Local half_iHeight = Floor( iHeight / 2 )
For y = 0 To iHeight-1
For x = 0 To iWidth-1
; x reprisents the rotation angle from 0 -> 360
; convert the x position into an angle
cx# = ( x - half_iWidth ) * ( 360.0 / Float(iWidth) )
; y is effectively the diameter
; the coords can also be scaled
; Finally move to the center of the Polar space
nx = ( xScale# * Sin( cx# ) * y ) + half_iWidth
ny = ( yScale# * Cos( cx# ) * y ) + half_iHeight
; ensure the pixel falls within the texture range
If ( nx < 0 ) Then nx = 0
If ( nx >= iWidth ) Then nx = iWidth - 1
If ( ny < 0 ) Then ny = 0
If ( ny >= iHeight ) Then ny = iHeight - 1
; read the texture pixel color
srcPixel = ReadPixel( x,y, TextureImage )
; write the pixel in Polar Space
WritePixel( nx,ny, srcPixel, PolarImage )
Next
Next
End Function
But can anyone else help with converting Polar to Texture space, i.e. Reversing the above equation?