# Why map Hammersley 2D set's (u,v) to sphere's (θ, φ) coordinates (and not to (φ, θ) )?

As explained in Holger Dammetz page Hammersley Points on the Hemisphere, the 2D coordinates (u,v) are usually mapped to the spherical coordinates (θ, φ). As a result, the coordinate "uniformly distributed" - u in the 2D case - is the polar angle θ. This looks counter-intuitive to me, I would have mapped regularly spaced u values to regularly spaced azimuth φ values. To avoid "empty areas" like in this example: which is generated by the mapping of the following 2D set: What is the reason not to map (u, v) to (φ, θ) ?

You can of course, as you suggested, map (u, v) to (φ, θ). Unfortunately, it does not solve the problem for 5 points: I've changed Holger Dammertz' code a bit (switched u and v), and you see that the problem still persists. For a higher number of points, it really doesn't seem to make a (visual) difference.

The Hammersley point set is a way to very quickly determine points on a sphere that have good, but don't need to have a perfect distribution. In the problematic case of very few points, Hammersley might just not be the tool for the job. Pre-calculating and storing points sounds like a better option to me.

The "Uniform Mapping" here is incorrect. It does not transform to a uniform distribution on the sphere.

Very very bad me. I misread the equation AND I didn't even consult my own reference , if I had I would have seen my mistake.

Still the method from  is interesting and is described below.

To map a uniform point set from the unit square to the sphere or half sphere requires an area-preserving map. That will maintain the uniform property. For pseudo-random that's sufficient (points are independent), however low-discrepancy point set will have its discrepancy measure effected by distortions in area introduced by the map. I'm not aware of any references with respect to this point.

The method from  starts by mapping unit square to the unit disk. One way we can do this is by using a rejection method. Pseudo-code looks like this:

d = 0;

do {
p = uniform2d(...);  // [0,1) x [0,1)   given to be uniform
p = 2p;              // [0,2) x [0,2)   scaling (area-preserving)
p = p-1;             // (-1,1) x (-1,1) translating (area-preserving)
d = dot(p,p);        // is p in disk?
} while(d >= 1);       //   if not rinse-and-repeat


the area of the transformed square is $4$ and the unit disk is $\pi$, so the acceptance rate is $\frac{\pi }{4}$ (~.785) so on average requires $\frac{4}{\pi}$ (~1.273) iterations.

Also non-rejection based methods exist, for example  which requires one square root and one trig operation. Note that the rejection method does not distort areas so the discrepancy measure remains the same.

Once we have $p = \left(u_0, u_1 \right)$ uniformly distributed in the unit disk, we have:

$$u_0, u_1 \in \left(-1,1\right)$$ $$d = p\cdot p = u_0^2+u_1^2,\; d < 1$$

then the transform to the sphere is:

$$s=2\sqrt{1-d}$$ $$p = \left\{s\thinspace u_0,\thinspace s\thinspace u_1, 1-2d\right\}$$

or if you wanted a half-sphere, say positive Z, (just to state the obvious):

$$p = \left\{s\thinspace u_0,\thinspace s\thinspace u_1, d\right\}$$

There is a Stackexchange: Mathematics thread that discusses this method (,).

Also if you want to procedurally generate a LDS the additive recurrence formulation of the Weyl sequence is very cheap.

References:

1. Wolfram MathWorld: Sphere Point Picking
2. "Choosing a Point from the Surface of a Sphere.", George Marsaglia, 1972. (PDF)
3. Wolfram MathWorld: Disk Point Picking
4. SE Mathematics
5. SE Mathematics
• Doh: actually I'm wrong about the method not being uniform...working on a rewrite. – MB Reynolds Mar 9 '16 at 10:57
• OK, I put up a first revision. – MB Reynolds Mar 9 '16 at 12:17
• Added the area-distortion note – MB Reynolds Mar 10 '16 at 9:13