Uniform sampling from part of sphere surface

1.1k Views Asked by At

I'd like to pose a question about uniform sampling on the surface of a sphere.

I searched this site, and uniform sampling on a sphere surface seems to be quite a common problem. The common solution is to take two uniform random numbers $u$ and $v$ between 0 and 1, then compute the spherical coordinates as follows:

$\theta = 2\pi u$ $\phi = \cos^{-1}(2v - 1)$

However, in my application I am required to sample a point uniformly on a small patch on the surface, namely with $\theta$ between $\theta_{min}$ and $\theta_{max}$ and with $\phi$ between $\phi_{min}$ and $\phi_{max}$. I could re-pick random numbers until these requirements are met, but since the patch can be quite small and efficiency is an issue (this is for a ray-tracer), I would like to know if there is an algebraic solution that involves limiting the range of the random numbers $u$ and $v$.

1

There are 1 best solutions below

0
On

Based on the pointers given by Stephen Montgomery-Smith and fgp in the comments above, I came to the following formulas. I computed $u_{min}$ and $u_{max}$ from the inverse of the formula for $\theta$: $u = \frac{\theta}{2 \pi}$. I computed $v_{min}$ and $v_{max}$ from the inverse of the formula for $\phi$: $v = \frac{\cos(\phi) + 1}{2}$. Plugging $\theta_{min}$, $\theta_{max}$, $\phi_{min}$ and $\phi_{max}$ into their respective formulae, I obtained $u_{min}$, $u_{max}$, $v_{min}$ and $v_{max}$.

From there on, it's a matter of taking a uniform random number between $u_{min}$ and $u_{max}$ by taking $u = u_{min} + random() * (u_{max} - u_{min})$ (and for $v$ similar).

Thanks for the help!