4

I want to map a grid to a sphere like this:

grid to sphere mapping

In other words, for every point (x, y) ∈[0,1] on the left, I need the (x, y, z) coordinates of the equivalent point on the sphere, between the -45º and +45º meridians on each axis. You can also think of the source coordinates as two angles such that:

phi   = -45º + x * 90º
theta = -45º + y * 90º

The traditional latitude-longitude or polar formulas I've found elsewhere are of no use because the results they produce are only distorted along one axis. Any other suggestions?

Community
  • 1
  • 1
User not found
  • 2,129
  • 2
  • 15
  • 20
  • Are you trying to simulate barrel distortion? If so, this may be helpful: http://stackoverflow.com/questions/6199636/formulas-for-barrel-pincushion-distortion – Blender Aug 16 '13 at 02:13
  • If I understand it correctly, barrel distortion is a purely two-dimensional effect? If so, I'm afraid it's not what I need. This is more like cube mapping. I'm generating procedural planets textured with cubemaps (think Spore) so I need it to be 3D. – User not found Aug 16 '13 at 02:34
  • This reminds me a lot a conformal mapping... Have you tried it already? – Pedrom Aug 16 '13 at 11:13

1 Answers1

1

Define two functions, a and b, that map your x and y coordinates to the appropriate theta and phi angles:

a(x) = (pi / 4) * (2x - 1)
b(y) = (pi / 4) * (4y + 1)

And then just map the resulting spherical coordinate back into a Cartesian coordinate:

enter image description here

You'll get a function of r, x', y', members of [0, 1] x [0, 1], which will map the 2D coordinate onto a sphere of radius r.

Blender
  • 289,723
  • 53
  • 439
  • 496
  • Thanks for the `a(x)` and `b(x)` mapping functions, they saved me some work. Unfortunately, the formulas for spherical coordinate mapping don't get me the results I need. I tried them out on Excel anyway and got this https://dl.dropboxusercontent.com/u/1735705/grid2sphere_blender_excel.jpg which confirmed my suspicions. It has to be some form of cube mapping, not ECP (latitude-longitude) mapping. – User not found Aug 16 '13 at 04:00