The parametric equation of the torus is: $$ \sigma(u, v) = \left((R + r \cos u) \cos v, (R + r \cos u) \sin v, r \sin u\right) $$

Where $R > r$ and $u$, $v$ change in $[0, 2\pi)$.

To get the parametric equation of a curve on the torus starting at $(x_0, y_0)$ and initially moving in the direction of $a\sigma_u + b\sigma_v$. Plug the following into the torus parametric equation:

$$ u = at + x_0 \\ v = bt + y_0 $$

Thus, the parametric equation of the curve becomes:

$$ \gamma(t) = \left((R + r \cos(at+x_0)) \cos(bt+y_0), (R + r \cos(at+x_0)) \sin(bt+y_0), r \sin(at+x_0)\right) $$

If $b \neq 0$ and $\dfrac{a}{b}$ is rational, the parameterization above is periodic and the curve is closed. If it's irrational, the curve never closes and is a dense subset of the torus. If $b = 0$, the curve is closed.

You can experiment with the above using WolframAlpha or any plotting software capable of plotting 3D parametric equations.

  1. Here is a closed curve on the torus.
  2. And here is a dense one. Increase the upper limit of $t$ to see how it covers more of the torus.

EDIT: In this answer, I have a formal proof that the curve is dense if $\dfrac{a}{b}$ ($\lambda$ in the answer) is irrational.


Every trajectory that corresponds to an oblique direction on the rectangle yields a path that wraps around the torus in a spiral fashion; consecutive loops are spaced equally around the ring. Either it closes after a finite number of loops, or it never closes, and the loops cover the surface of the torus more and more densely. The path as a whole is a dense subset of the torus.