polar to cartesian ?

I see a nice example of cartesian-to-polar, but I haven’t found the reverse. Anybody done the math? it looks like bergi’s ‘cube-map to fisheye shader’ has it in there, but I haven’t been able to glean it out since it’s in GLSL coding

uniform sampler2D sInput1;
varying vec2 texcoord0;
varying vec2 texdim0;

const float pi=3.1415926;

void main(void)
{
vec2 normalizedCoords = texcoord0/texdim0; //[0 → 1];
normalizedCoords = 2.0 * normalizedCoords - 1.0;

``````float theta =  (2*pi) - normalizedCoords.x * (-pi);

//float theta =  (pi) + normalizedCoords.x * (pi);

float r =  (1.0 + normalizedCoords.y) * 0.5;

vec2 cartesian = vec2 (-r * sin(theta),r * cos(theta));

cartesian = ( (cartesian/2.0) + 0.5) * texdim0;
gl_FragColor = texture2D(sInput1, cartesian);
``````

}

varying vec2 texcoord0;
varying vec2 texcoord1;
varying vec2 texdim0;
varying vec2 texdim1;
varying vec2 texorient0;
varying vec2 texorient1;

void main()
{

``````gl_Position = ftransform();
texcoord0 = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);
texcoord1 = vec2(gl_TextureMatrix[1] * gl_MultiTexCoord1);
texdim0 = vec2 (abs(gl_TextureMatrix[0][0][0]),abs(gl_TextureMatrix[0][1][1]));
texdim1 = vec2 (abs(gl_TextureMatrix[1][0][0]),abs(gl_TextureMatrix[1][1][1]));
texorient0 = vec2 (gl_TextureMatrix[0][0][0]/texdim0.x,gl_TextureMatrix[0][1][1]/texdim0.y);
texorient1 = vec2 (gl_TextureMatrix[1][0][0]/texdim1.x,gl_TextureMatrix[1][1][1]/texdim1.y);
``````

}