Embedded torus of revolution (source code)

= Embedded torus of revolution

For major radius $R$ and minor radius $r$ with $R>r>0$, the standard embedded torus of revolution in $\mathbb R^3$ is
$$
(\sqrt{x^2+y^2}-R)^2+z^2=r^2.
$$
It is parametrized by
$$
(s,t)\longmapsto
\bigl((R+r\cos 2\pi t)\cos2\pi s,
(R+r\cos2\pi t)\sin2\pi s,
r\sin2\pi t\bigr),
$$
which identifies the opposite sides of the unit square.