meshlabxml/mp_func.py
def torus_knot(t, p=3, q=4, scale=1.0, radius=2.0):
    """ A tight (small inner crossings) (p,q) torus knot parametric curve

    Source (for trefoil): https://en.wikipedia.org/wiki/Trefoil_knot

    """
    return ['{scale}*(sin({t}) + ({radius})*sin({p}*({t})))'.format(t=t, p=p, scale=scale, radius=radius),
            '{scale}*(cos({t}) - ({radius})*cos({p}*({t})))'.format(t=t, p=p, scale=scale, radius=radius),
            '{scale}*(-sin({q}*({t})))'.format(t=t, q=q, scale=scale)]
def torus_knot(t, p=3, q=4, scale=1.0, radius=2.0):
    """ A tight (small inner crossings) (p,q) torus knot parametric curve

    Source (for trefoil): https://en.wikipedia.org/wiki/Trefoil_knot

    """
    return ['{scale}*(sin({t}) + ({radius})*sin({p}*({t})))'.format(t=t, p=p, scale=scale, radius=radius),
            '{scale}*(cos({t}) - ({radius})*cos({p}*({t})))'.format(t=t, p=p, scale=scale, radius=radius),
            '{scale}*(-sin({q}*({t})))'.format(t=t, q=q, scale=scale)]
A tight (small inner crossings) (p,q) torus knot parametric curve

    Source (for trefoil): https://en.wikipedia.org/wiki/Trefoil_knot