In this notebook I plot a helix with its unit tangent vectors at a collection of points.
The "standard" parametrization of the helix, $\mathbf{r}(t) = \langle \cos t, \sin t, t \rangle$, is used on the interval $[-4\pi,4\pi]$. Python functions are defined to compute the component-wise derivatives and unit tangent vectors at a given point. Finally, the tangent vectors are plotted at 10 points along the curve.
This was all done using SageMath (http://sagemath.org) in a web-based Jupyter notebook (http://jupyter.org).
version()
%display latex
Define the helix with the standard parametrization from above:
t = var('t');
r = [cos(t),sin(t),t];
r
Plot four periods of the helix in a reasonable window:
helix = parametric_plot3d(r,(-4*pi,4*pi),aspect_ratio=(1,1,1/(2*pi)),plot_points=1000,viewer='tachyon')
show(helix)
Define python functions that will compute component-wise derivatives, vector lengths (or norms), and the unit tangent vectors at given points.
def ceval(vf,pt):
n = len(vf);
out = [None]*n;
for i in range(n):
out[i] = vf[i](t = pt).full_simplify();
return out
def cder(vf,pt):
n = len(vf);
vfd = [None]*n;
out = [None]*n;
for i in range(n):
vfd[i] = vf[i].diff()
out = ceval(vfd,pt)
return out
def norm(vf):
n = len(vf);
A = sum(vf[i]**2 for i in range(n));
nm = sqrt(A);
return nm.full_simplify()
def tang(vf,pt):
n = len(vf);
tn = [None]*n;
tt = cder(vf,pt);
ttt = norm(tt);
for i in range(n):
tn[i] = tt[i]/ttt.full_simplify();
return tn
Choose some points on the helix:
pts = [None]*10;
for i in range(10):
pts[i] = -4*pi + i*8*pi/9;
ppts = sum(plot(vector(tang(r,pts[j])),start=ceval(r,pts[j]),color='red',viewer='tachyon') for j in range(10));
show(helix + ppts)