----
# Trefoil knot tube
t, u = SR.var('t u')
assume(t, u, 'real')
# First define the Trefoil knot spacecurve
r = vector((sin(3 * t), 2 * sin(2 * t) + sin(t), cos(t) - 2 * cos(2 * t)))
# Next compute the T, N, and B vectors
rp = diff(r, t)
T = rp / rp.norm()
Tp = diff(T, t)
N = Tp / Tp.norm(2)
B = T.cross_product(N)
# Define the function to use for the radius of the circle
radius(t) = 1/2
# Define the vector function for the surface and plot it
tube = r + radius(t) * cos(u) * N + radius(t) * sin(u) * B
parametric_plot3d(tube, (t, 0, 2 * pi), (u, 0, 2 * pi),
plot_points=[100, 30], aspect_ratio=[1, 1, 1]
viewer='threejs')
----
----
# The cone
u, v = var('u v')
assume(u, v, 'real')
# Define the surface as a vector function
r = vector((v * cos(u), v * sin(u), v))
# Plot it
parametric_plot3d(r, (u, 0, 2*pi), (v, 0, 5), aspect_ratio=[1, 1, 1],
viewer='threejs')