Torus helix radius change equation If we draw a closed helix trajectory on the surface of a torus (with helix center axis corresponding to that of torus), the radius will cyclically change between inner and outer radius (r and R). Can anyone point me to a function that describes dependency between position on the trajectory and radius of the helix at that point?  
 A: The usual parametrization of a torus with inner radius $r$ and outer radius $R$ is via latitude $\phi$ and longitude $\theta$:
$$
\left\{
\begin{array}{l}
x(\phi, \theta) := \left(\frac{R + r}{2} + \frac{R-r}{2}\cos \phi \right) \cos \theta \\
y(\phi, \theta) := \left(\frac{R + r}{2} + \frac{R-r}{2}\cos \phi \right) \sin \theta \\
z(\phi, \theta) := \frac{R-r}{2} \sin \phi \\
\end{array}
\right. ,
$$
and one can produce a helix of the sort you describe by composing this map with a straight line through the parameter space, say, $\gamma(t) = (\alpha t, \beta t)$, giving the curve
$$
\left\{
\begin{array}{l}
x(t) := \left(\frac{R + r}{2} + \frac{R-r}{2}\cos \alpha t \right) \cos \beta t \\
y(t) := \left(\frac{R + r}{2} + \frac{R-r}{2}\cos \alpha t \right) \sin \beta t\\
z(t) := \frac{R-r}{2} \sin \alpha t \\
\end{array}
\right. .
$$
Here, the magnitude of the ratio $\lambda := \beta / \alpha$ is the number of times the curve wraps around the torus the longitudinal direction for each time it wraps around the latitudinal direction, and the sign of the ratio controls whether the helix travels clockwise or anticlockwise. The curve will close up on itself iff $\lambda$ is rational (or if $\alpha$ is zero, in which case, like when $\beta = 0$, the curve is just a circle, which we can regard as a degenerate torus).
In the curve in your illustration, $r$ looks to be $0$; we call this shape a horn torus, and in this case the above expressions simplify a little. Here's a plot of the curve with $R = 2, r = 0, \lambda = -12$, which approximates the illustration reasonably well:

