I've been researching image warping algorithms lately and haven't found many comprehensive references. That said, there are of course code snippets from GIMP, jhlabs.com, and imagemagick.org but none of these explain the mathematics behind the process. This stackoverflow post gives a very nice and concise example of the bulge warp effect, but it also lacks detailed explanation. Here is the meat of the math: Suppose your image coordinates go from 0 to 1.
If you define:
r = Sqrt[(x - .5)^2 + (y - .5)^2] a = ArcTan[x - .5, y - .5] rn = r^2.5/.5 /* NB: arctan is not really necessary since Cos[a] = (x - .5)/r and Sin[a] = (y - .5)/r */
And then remap your pixels according to:
x -> rn*Cos[a] + .5 y -> rn*Sin[a] + .5
Result:
So the question is, what exactly mathematically is going on here? Why does this produce the circular bulge warp? If I wanted the bulge to expand in, say, a triangular pattern, or perhaps with a bias of weighted points rather than equally in all directions, how would I change the trigonometry functions (if at all - a constraint over the given circular pattern might make more sense)?