I am trying to make a $(2,3)$ trefoil knot from equations \begin{align*} x &= (a + b\cos(3t))\cos(2t), \\ y &= (a + b\cos(3t))\sin(2t), \\ z &= b\sin(3t) \end{align*} where the major radius $a = 26.7$ mm and the minor radius $b = 13.3$ mm. This trefoil knot resides on surface of a torus having same major radius and minor radius.
But my problem is when I try to thicken the trefoil knot wire or try to give it a radius of $4$ mm, it will not reside on torus surface. Some portion of it goes into torus. Kindly help me with this.
You've parametrized the knot by a regular function $\gamma: t \mapsto \gamma(t) \in \mathbb{R}^3$. You now want to put a tube around it with radii $(a,b)$. Use the following map,
$$ \Gamma(t,\theta) = \gamma(t) + a\textbf{N}(t) \cos(\theta) + b\textbf{B}(t) \sin(\theta)$$
This will give you the elliptical tubing that you want. Here $\textbf{N},\textbf{B}$ are the unit normal and binomal vectors to the Frenet Frame at $\gamma(t)$.
$\textbf{Example}$: Take $S^1$. Let $\gamma(t) = (\cos t, \sin t, 0)$ and $\textbf{N} = (\cos t, \sin t,0), \textbf{B}(t) = (0,0,1)$.
$$\Gamma(t, \theta) = \begin{pmatrix} \cos t \\ \sin t \\ 0 \end{pmatrix} + \begin{pmatrix} a \cos \theta (\cos t) \\a \cos \theta ( \sin t) \\ 0 \end{pmatrix} + \begin{pmatrix}0 \\ 0 \\ b \sin \theta \end{pmatrix} = \begin{pmatrix} \cos t + a\cos \theta \cos t \\ \sin t + a \cos \theta \sin t \\ b \sin \theta \end{pmatrix}$$
I hollowed the image so you could see the elliptic tubing.