TITLE: derive a parametric equation of a sphere (on the first octant) with a dent in the middle
QUESTION [8 upvotes]: I was trying to derive the surface equation of a sphere where there is a dent in the middle of the surface. I am drawing on the first octant. I want the dent to be formed by changing the radius.
the equation of the radius:
$$r(x,y) = \frac{1}{2}(\cos(2\pi K x) + \cos(2\pi K y))\quad K = 1 \quad (K = \text{number of dents})$$
and the parametric equation of the surface looks like this:
$$
\begin{eqnarray}
f_x(u,v) &=& r(u,v) \cos(u\frac{\pi}{2}) \cos(v\frac{\pi}{2})\\
f_y(u,v) &=& r(u,v) \cos(u\frac{\pi}{2}) \sin(v\frac{\pi}{2})\\
f_z(u,v) &=& r(u,v) \sin(u\frac{\pi}{2})\\
&& \text{where,}\quad 0 \leq u,v \leq 1
\end{eqnarray}
$$
If I plot $r(x,y)$ within $0 \leq x,y \leq 1$, I get this:

Now if I draw the parametric equation, I get this:

To make a proper adjustment, I change $r(x,y)$ to this:
$$r(x,y) = 5 + (\cos(2\pi K x) + \cos(2\pi K y))\quad K = 1$$
Now, if I draw it again, I get this:

Still, if you look at the top of the z-axis, a fold appears which I do not want. Moreover, the scale of the sphere is changed, the radius has been changed to $[0.0, 7.0]$. But what I need is a unit sphere on the first octant without any fold on the top and the lowest point of the dent appears at $(0.5,0.5,0.5)$ coordinate (instead of $(3.5, 3.5, 2.xx)$-ish). How do I do it properly? Moreover, can I do it without $r()$ being a surface? Please help.

REPLY [2 votes]: You have not been very precise on what you were exactly looking for, but this should serve as a good basis.
The idea is to use a Gaussian to make the dent. The number of dents in $\theta$ is denoted by $n_\theta$, and $n_\phi$ in $\phi$.
Then, introducing some parameters controlling depth ($d$), "sharpness" ($s$), you can use something like:
$$r(\theta,\phi)=1-d\exp\big(s(\sin(n_\theta \theta)^2+\sin(n_\phi \phi)^2)\big)$$
in the parametrization of the sphere $r(\cos(\theta)\sin(\phi),\sin(\theta)\sin(\phi),\cos(\theta))$.
The following Mathematica code provides an example and can be adapted to produce the following animations. The result is better when $n_\theta$ and $n_\phi$ are close.
d = .2; c = 4.; d = 0.03; s = 1.2; np = 8; nt = 5.;
r[theta_, 
   phi_] := (1 - d*Exp[-s*(-Sin[np*phi]^2 - Sin[nt*theta]^2)]);
ParametricPlot3D[
 r[theta, phi]*{Cos[theta] Sin[phi], Sin[theta] Sin[phi], 
   Cos[phi]}, {theta, 0, 2 Pi}, {phi, 0, Pi}, Boxed -> False, 
 Axes -> False, Mesh -> None, PlotPoints -> 25, 
 PlotLegends -> {"np=" <> ToString[np] <> ", nt=" <> ToString[2 nt]}]

Influence of depth $d$: