How would I find a point on a sphere with a UV coordinate? I'd like to do the opposite of the example specified here: https://en.wikipedia.org/wiki/UV_mapping
Can somebody explain to me how to do it?
Thanks,
For any point $P$ on the sphere, calculate $\hat d$, that being the unit vector from $P$ to the sphere's origin.
Assuming that the sphere's poles are aligned with the $Y$ axis, UV coordinates in the range $[0, 1]$ can then be calculated as follows:
\begin{align}
u &= 0.5 + \frac{\text{arctan2}(d_z, d_x)}{2\pi}
\\
v &= 0.5 - \frac{\arcsin(d_y)}{\pi}
\end{align}
 A: Given that $\hat d$ is a unit vector satisfying the equations
\begin{align}
u &= 0.5 + \frac{\text{arctan2}(d_z, d_x)}{2\pi} \quad \text{and}
\\
v &= 0.5 - \frac{\arcsin(d_y)}{\pi},
\end{align}
we have
\begin{align}
\text{arctan2}(d_z, d_x) &= 2\pi(u - 0.5) \quad \text{and}
\\
\arcsin(d_y) &= \pi(0.5 - v)
\end{align}
where $u,v \in [0,1]$.
The $d_y$ coordinate is easily dealt with:
$$d_y = \sin(\pi(0.5 - v)).$$
The $\text{arctan2}$ function is a little harder to invert because we have only
one output parameter for two input parameters. But the input to the function
can be known up to some positive factor $r > 0$:
\begin{align}
d_z & = r \cos(2\pi(u - 0.5)) \quad \text{and}
\\
d_x & = r \sin(2\pi(u - 0.5)).
\end{align}
(That assumes $\text{arctan2}(\cos\theta, \sin\theta) = \theta$
for $-\pi < \theta < \pi$; if this is the
version of $\text{arctan2}$ such that
$\text{arctan2}(\sin\theta, \cos\theta) = \theta$,
which is more usual in software libraries,
then swap the sin and cos functions in the formulas above.)
With the added constraint that $d_x^2 + d_y^2 + d_z^2 = 1$,
we have $r^2 + \sin^2(\pi(0.5 - v))$ and therefore $r = \cos(\pi(0.5 - v))$.
Putting all of this together,
\begin{align}
d_x & = \cos(\pi(0.5 - v)) \sin(2\pi(u - 0.5)), \\
d_y & = \sin(\pi(0.5 - v)), & \text{and} \\
d_z & = \cos(\pi(0.5 - v)) \cos(2\pi(u - 0.5)).
\end{align}
A: Would
$$
(r\cos u\sin v, r\sin u \sin v, r\cos v) 
$$
be what you're looking for? In this case, $r$ is the radius of the sphere, $u$ goes from $0^\circ$ to $360^\circ$ (or from $-180^\circ$ to $180^\circ$ if you want) while $v$ goes from $-90^\circ$ to $90^\circ$.
The triple $(r, u, v)$ is called spherical coordinates of the point with the rectangular coordinates as above.
