This might be more of a mathematical problem than a Mathematica'l one, but still, maybe you'd help me.
I want to write a function that would produce a rectangular image from an image with Hammer projection (the next step would be to map that rectangular image to a sphere, so perhaps this step might be skipped altogether, but these problems are mathematically equivalent, I suspect).
So I use this guide to write down transformation functions, and my code looks like this:
z[x_, y_] := Sqrt[1 - (x/4)^2 - (y/2)^2];
lambda[x_, y_] := 2 ArcTan[(z[x, y] x)/(2 (2 (z[x, y])^2 - 1))];
phi[y_, m_] := ArcSin[y m];
Hammertoequirect[{k_, j_}] := {lambda[k, j], phi[k, z[k, j]]};
Hammer = Import[
"http://paulbourke.net/geometry/transformationprojection/aitoff1_s.\
gif"];
equirect =
ImageForwardTransformation[Hammer, Hammertoequirect,
DataRange -> {{-1, 1}, {-1, 1}}]
And as a result, I get something utterly horrifying - like that:
As might be expected, I'm not quite happy with the outcome.
I noticed that changing the DataRange changes the result, so perhaps the problem lies here (but I couldn't determine the proper value). Or maybe these gray areas at the edges of the original image should be white or transparent to get a proper result?..
Or maybe the problem is in trigonometric functions giving radians instead of degrees or in the fact that they're ambiguous in terms of sign of the argument etc., but again, I could not determine the proper form of the expressions anyway.
EDIT: As a commenter asked, I clarify: I want to get a rectangular image with a rectangular grid (so just a bunch of equidistant vertical and horizontal lines) from this image with Hammer projection grid (it's just a sample to see if the function works properly, later I'm gonna use other image instead).
If the projection is done properly, the gray areas at the edges should disappear (as I understand the procedure) - perhaps, being mapped to the very edge of the resulting rectangle.