Loading modules
import knoty
import k3d
import sympy as sp
import numpy as np
Defining a contact structure¶
We can define arbitrary 1 forms and use them in the package. For the package to work correctly these forms need to be contact structures. Contact structures in this package are specified by the coefficients of the basis elements $dx$, $dy$ and $dz$. The default contact structure used in this package is
$$ xdy + dz.$$
This would be equivalent to the following expression
form = [0, 'x', 1]
Plotting contact structure¶
We can now plot this using the plot_contact_structure() function
plot = k3d.plot()
plot = knoty.plot_contact_structure(plot, form = form, alpha = 0.6)
plot.display()
Defining knots through equations¶
In this package knots are functions going from R to R3. Below you'll find two examples for unknots.
def knot1(t):
return 3 * sp.sin(2 * np.pi *t) * sp.cos(2 * np.pi *t), sp.cos(2 * np.pi *t), sp.sin(2 * np.pi *t)**3
def knot2(t):
return sp.cos(2 * np.pi *t), sp.sin(2 * np.pi *2*t), 2/3 * sp.sin(2 * np.pi *t)*sp.cos(2 * np.pi *2*t) -4/3 * sp.sin(2 * np.pi *2*t)*sp.cos(2 * np.pi *t)
Plotting Knots¶
We can plot the knots using the plot_knot() function.
plot = k3d.plot()
plot = knoty.plot_knot(plot, knot1, domain=[0,8], resolution=500)
plot = knoty.plot_planes_along_knot(plot, knot1, n = 30, size=0.1)
plot.display()
plot = k3d.plot()
plot = knoty.plot_knot(plot, knot2, domain=[0,8], resolution=500)
plot = knoty.plot_planes_along_knot(plot, knot2, n = 30, size=0.1)
plot.display()
Included knot examples¶
The package currently includes 6 example equations for Legendrian knots, namely
- unknot1
- unknot2
- LNLegLHTrefoil definded on [0,8]
- LNLegTrefoil defined on [0,10]
- LNChekanovA defined on [0,18]
- LNChekanovB defined on [0,18]
The equations were kindly provided by Lenny Ng. The last four knots are for the contact structure
$$ ydx -dz. $$
We therefore need to pass this contact structure into the plot_planes_along_knot() function for it to plot the correct surfaces. Furthermore, as the domain is not [0,1] we need to pass the domain of the knots into the functions.
plot = k3d.plot()
plot = knoty.plot_knot(plot, knoty.LNLegTrefoil, domain=[0,8], resolution=500)
plot = knoty.plot_planes_along_knot(plot, knoty.LNLegTrefoil, domain=[0,8], n = 30, size=0.2, form=['y', 0, -1])
plot.display()
plot = k3d.plot()
plot = knoty.plot_knot(plot, knoty.LNLegLHTrefoil, domain=[0,10], resolution=500)
plot = knoty.plot_planes_along_knot(plot, knoty.LNLegLHTrefoil, domain=[0,10], n = 80, form=['y', 0, -1], size=0.1)
plot.display()
plot = k3d.plot()
plot = knoty.plot_knot(plot, knoty.LNChekanovA, domain=[0,18], resolution=500)
plot = knoty.plot_planes_along_knot(plot, knoty.LNChekanovA, domain=[0,18], n = 80, form=['y', 0, -1], size=0.1)
plot.display()
plot = k3d.plot()
plot = knoty.plot_knot(plot, knoty.LNChekanovB, domain=[0,18], resolution=500)
plot = knoty.plot_planes_along_knot(plot, knoty.LNChekanovB, domain=[0,18], n = 80, form=['y', 0, -1], size=0.1)
plot.display()
Stacking Visualizations¶
We can also stack different visualizations ontop of each other as follows:
plot = k3d.plot()
plot = knoty.plot_knot(plot, knot2, domain=[0,8], resolution=500)
plot = knoty.plot_planes_along_knot(plot, knot2, n = 30, size=0.1)
plot = knoty.plot_contact_structure(plot, alpha = 0.1)
plot.display()
We can also get a quick intuition for the tb of a knot by shifting a knot and plotting both.
def knot2tb(t):
return sp.cos(2 * np.pi *t), sp.sin(2 * np.pi *2*t), 2/3 * sp.sin(2 * np.pi *t)*sp.cos(2 * np.pi *2*t) -4/3 * sp.sin(2 * np.pi *2*t)*sp.cos(2 * np.pi *t) + 1
plot = k3d.plot()
plot = knoty.plot_knot(plot, knot2, domain=[0,8], resolution=500)
plot = knoty.plot_knot(plot, knot2tb, domain=[0,8], resolution=500)
plot.display()
Loading in a front projection¶
We can also load in a front projection specified by an SVG. The result will be a function for the knot that is compatible with all other functions provided by the package. The import does some automatic corrections to the knot to ensure continuity. See the documentation for more details.
import knoty
import k3d
svg_file = './Examples/Blatt4A21.svg' # Replace with your SVG file path
svg_knot = knoty.import_from_svg(svg_file, threshold=0.5)
We can now work with this knot equation svg_knot just as we did with the knots defined through equations
plot = k3d.plot(grid_visible=True,menu_visibility=False, axes=['y', 'x', 'z'])
plot = knoty.plot_knot(plot, svg_knot, resolution=100)
plot = knoty.plot_planes_along_knot(plot, svg_knot, n = 8, size=0.1)
plot.display()