<p>You can of course, as you suggested, map (u, v) to (φ, θ). Unfortunately, it does not solve the problem for 5 points:</p>

<p><a href="https://i.sstatic.net/csMKn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/csMKn.png" alt="Switched mapping"></a></p>

<p>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.</p>

<p>The Hammersley point set is a way to <strong>very quickly</strong> 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.</p>

CC BY-SA 3.0
2016-02-24T14:37:14.710Z
2016-02-24T14:37:14.710Z
David Kuri
<p><strike>The &quot;Uniform Mapping&quot; here is incorrect.  It does not transform to a uniform distribution on the sphere.</strike></p>
<p>Very very bad me.  I misread the equation AND I didn't even consult my own reference [1], if I had I would have seen my mistake.</p>
<p>Still the method from [2] is interesting and is described below.</p>
<h1>Additional note:</h1>
<p>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.</p>
<hr />
<p>The method from [2] 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:</p>
<pre><code>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 &gt;= 1);       //   if not rinse-and-repeat
</code></pre>
<p>the area of the transformed square is <span class="math-container">$4$</span> and the unit disk is <span class="math-container">$\pi$</span>, so the acceptance rate is <span class="math-container">$\frac{\pi }{4}$</span> (~.785) so on average requires <span class="math-container">$\frac{4}{\pi}$</span> (~1.273) iterations.</p>
<p>Also non-rejection based methods exist, for example [3] 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.</p>
<hr />
<p>Once we have <span class="math-container">$ p = \left(u_0, u_1 \right) $</span> uniformly distributed in the unit disk, we have:</p>
<p><span class="math-container">$$ u_0, u_1 \in \left(-1,1\right) $$</span>
<span class="math-container">$$ d = p\cdot p = u_0^2+u_1^2,\; d &lt; 1 $$</span></p>
<p>then the transform to the sphere is:</p>
<p><span class="math-container">$$ s=2\sqrt{1-d} $$</span>
<span class="math-container">$$ p = \left\{s\thinspace u_0,\thinspace s\thinspace u_1, 1-2d\right\} $$</span></p>
<p>or if you wanted a half-sphere, say positive Z, (just to state the obvious):</p>
<p><span class="math-container">$$p = \left\{s\thinspace u_0,\thinspace s\thinspace u_1, d\right\} $$</span></p>
<p>There is a Stackexchange: Mathematics thread that discusses this method ([4],[5]).</p>
<hr />
<p>Also if you want to procedurally generate a LDS the additive recurrence formulation of the Weyl sequence is very cheap.</p>
<hr />
<p>References:</p>
<ol>
<li><a href="http://mathworld.wolfram.com/SpherePointPicking.html" rel="nofollow noreferrer">Wolfram MathWorld: Sphere Point Picking</a></li>
<li>&quot;Choosing a Point from the Surface of a Sphere.&quot;, George Marsaglia, 1972. (<a href="http://projecteuclid.org/euclid.aoms/1177692644;" rel="nofollow noreferrer">PDF</a>)</li>
<li><a href="http://mathworld.wolfram.com/DiskPointPicking.html" rel="nofollow noreferrer">Wolfram MathWorld: Disk Point Picking</a></li>
<li><a href="https://math.stackexchange.com/questions/838326/3-random-numbers-to-describe-point-on-a-sphere/838336#838336">SE Mathematics</a></li>
<li><a href="https://math.stackexchange.com/questions/838326/3-random-numbers-to-describe-point-on-a-sphere/838882#838882">SE Mathematics</a></li>
</ol>

CC BY-SA 3.0
2016-03-09T10:57:04.507Z
Doh:  actually I'm wrong about the method not being uniform...working on a rewrite.
MB Reynolds
CC BY-SA 3.0
2016-03-09T12:17:30.033Z
OK, I put up a first revision.
MB Reynolds
CC BY-SA 3.0
2016-03-10T09:13:11.253Z
Added the area-distortion note
MB Reynolds
CC BY-SA 3.0
2016-03-08T13:10:25.380Z
2016-03-10T09:11:45.747Z
2020-06-18T08:32:12.800Z
MB Reynolds
<p>As explained in Holger Dammetz page <a href="http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html" rel="noreferrer">Hammersley Points on the Hemisphere</a>, the 2D coordinates (u,v) are usually mapped to the spherical coordinates (θ, φ).
<a href="https://i.sstatic.net/zOAcc.png" rel="noreferrer"><img src="https://i.sstatic.net/zOAcc.png" alt="enter image description here"></a><br>
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:<br>
<a href="https://i.sstatic.net/R0lK7.png" rel="noreferrer"><img src="https://i.sstatic.net/R0lK7.png" alt="enter image description here"></a><br>
which is generated by the mapping of the following 2D set:<br>
<a href="https://i.sstatic.net/9DZEr.png" rel="noreferrer"><img src="https://i.sstatic.net/9DZEr.png" alt="enter image description here"></a><br>
What is the reason not to map (u, v) to (φ, θ) ?</p>

<2d><sampling><mapping><distribution><hemisphere>
Why map Hammersley 2D set's (u,v) to sphere's (θ, φ) coordinates (and not to (φ, θ) )?
wip
# Why map Hammersley 2D set's (u,v) to sphere's (θ, φ) coordinates (and not to (φ, θ) )?

(Asked by: username_0 on 2016-02-23)

As explained in Holger Dammetz page [Hammersley Points on the Hemisphere](http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html), the 2D coordinates (u,v) are usually mapped to the spherical coordinates (θ, φ).
[![enter image description here](https://i.sstatic.net/zOAcc.png)](https://i.sstatic.net/zOAcc.png)  
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:  
[![enter image description here](https://i.sstatic.net/R0lK7.png)](https://i.sstatic.net/R0lK7.png)  
which is generated by the mapping of the following 2D set:  
[![enter image description here](https://i.sstatic.net/9DZEr.png)](https://i.sstatic.net/9DZEr.png)  
What is the reason not to map (u, v) to (φ, θ) ?

**Tags:** 2d, sampling, mapping, distribution, hemisphere


---

## 2 answers

### Answer by username_1 on 2016-02-24. Score: 4 | Accepted answer

You can of course, as you suggested, map (u, v) to (φ, θ). Unfortunately, it does not solve the problem for 5 points:

[![Switched mapping](https://i.sstatic.net/csMKn.png)](https://i.sstatic.net/csMKn.png)

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.


---

### Answer by username_2 on 2016-03-08. Score: 1

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 [1], if I had I would have seen my mistake.

Still the method from [2] is interesting and is described below.

# Additional note:

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 [2] 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 [3] 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 ([4],[5]).

---

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](http://mathworld.wolfram.com/SpherePointPicking.html)
2. "Choosing a Point from the Surface of a Sphere.", George Marsaglia, 1972. ([PDF](http://projecteuclid.org/euclid.aoms/1177692644;))
3. [Wolfram MathWorld: Disk Point Picking](http://mathworld.wolfram.com/DiskPointPicking.html)
4. [SE Mathematics](https://math.stackexchange.com/questions/838326/3-random-numbers-to-describe-point-on-a-sphere/838336#838336)
5. [SE Mathematics](https://math.stackexchange.com/questions/838326/3-random-numbers-to-describe-point-on-a-sphere/838882#838882)

> **Comments:**
> **username_2**: Doh:  actually I'm wrong about the method not being uniform...working on a rewrite.  
> **username_2**: OK, I put up a first revision.  
> **username_2**: Added the area-distortion note  

---

