(* Caricare in memoria le definizioni dei seguenti comandi con Shift+Enter *)

(* Esempio di funzione vettoriale f(t) rappresentante una curva parametrica *)
f[t_]:={Sin[t],Sin[2t],Cos[t]}
(* |v|=(v.v)^(1/2)  modulo di un vettore v *)
modulo[v_]:=(v.v)^(1/2) 
(* versore tangente per la generica curva g[t] *)
tangent[g_][t_]:=Simplify[D[g[tt],tt]/modulo[D[g[tt],tt]]]/.tt->t 
(* versore binormale per la generica curva g[t] *)
binormal[g_][t_]:=Simplify[Cross[D[g[tt],tt],D[g[tt],{tt,2}]]/modulo[Cross[D[g[tt],tt],D[g[tt],{tt,2}]]]]/.tt->t
(* versore normale per la generica curva g[t] *)
normal[g_][t_]:=Simplify[Cross[binormal[g][t],tangent[g][t]]]
(* curvatura della generica curva g[t] *)
c[g_][t_]:= Simplify[modulo[Cross[D[g[tt],tt],D[g[tt],{tt,2}]]]/modulo[D[g[tt],tt]]^3] /. tt->t
(* torsione della generica curva g[t] *)
tor[g_][t_]:=Simplify[Cross[D[g[tt],tt],D[g[tt],{tt,2}]].D[g[tt],{tt,3}]/modulo[Cross[D[g[tt],tt],D[g[tt],{tt,2}]]]^2] /. tt->t

Manipulate[Show[{
ParametricPlot3D[f[t],{t,0,2Pi}],
Graphics3D[{Red,Sphere[f[tfix],0.03]}],
Graphics3D[{Red,Line[{f[tfix],f[tfix]+0.3tangent[f][tfix]}],Green,Line[{f[tfix],f[tfix]+0.3normal[f][tfix]}],Blue,Line[{f[tfix],f[tfix]+0.3binormal[f][tfix]}]}]
}],{tfix,0,2Pi}]

Manipulate[Show[{
ParametricPlot3D[f[t],{t,0,2Pi}],
Graphics3D[{Sphere[f[tfix],0.04]}],
Graphics3D[{Red,Cylinder[{f[tfix],f[tfix]+0.3tangent[f][tfix]},.02],Green,Cylinder[{f[tfix],f[tfix]+0.3normal[f][tfix]},.02],Blue,Cylinder[{f[tfix],f[tfix]+0.3binormal[f][tfix]},.02]}]
}],{tfix,0,2Pi}]

Manipulate[Show[{
ParametricPlot3D[f[t],{t,0,2Pi},PlotLabel->f[t],PlotLegends->PointLegend[{Red,Blue,Green},{"tangente","normale","binormale"}]],
Graphics3D[{Sphere[f[tfix],0.04]}],
Graphics3D[{Red,Arrow[Tube[{f[tfix],f[tfix]+0.3tangent[f][tfix]},.01]],Green,Arrow[Tube[{f[tfix],f[tfix]+0.3normal[f][tfix]},.01]],Blue,Arrow[Tube[{f[tfix],f[tfix]+0.3binormal[f][tfix]},.01]]}]
}],{tfix,0,2Pi}]

Plot[c[f][t],{t,0,2Pi}]

Plot[tor[f][t],{t,0,2Pi}]

Manipulate[GraphicsRow[{Show[{
ParametricPlot3D[f[t],{t,0,2Pi},Axes->None,PlotLabel->f[t]],
Graphics3D[{Sphere[f[tfix],0.04]}],
Graphics3D[{Red,Arrow[Tube[{f[tfix],f[tfix]+0.3tangent[f][tfix]},.01]],Green,Arrow[Tube[{f[tfix],f[tfix]+0.3normal[f][tfix]},.01]],Blue,Arrow[Tube[{f[tfix],f[tfix]+0.3binormal[f][tfix]},.01]]}]
}],Plot[{c[f][t],tor[f][t]},{t,0,2Pi},Epilog->{PointSize[.02],Point[{{tfix,c[f][tfix]},{tfix,tor[f][tfix]}}]}]},ImageSize->700],{tfix,0,2Pi}]

h[t_]:={Sin[2t],Sin[3t],Cos[t]}

Module[{g=h,tau,b,n,cv,trs},
tau[t_]=tangent[g][t];
n[t_]=normal[g][t];
b[t_]=binormal[g][t];
cv[t_]=c[g][t];
trs[t_]=tor[g][t];
Manipulate[
GraphicsRow[{Show[{
ParametricPlot3D[g[t],{t,0,2Pi},Axes->None,PlotLabel->g[t]],
Graphics3D[{Sphere[g[tfix],0.04]}],
Graphics3D[{Red,Arrow[Tube[{g[tfix],g[tfix]+0.3tau[tfix]},.01]],Green,Arrow[Tube[{g[tfix],g[tfix]+0.3n[tfix]},.01]],Blue,Arrow[Tube[{g[tfix],g[tfix]+0.3b[tfix]},.01]]}]
}],Plot[{cv[t],trs[t]},{t,0,2Pi},PlotRange->All,Epilog->{PointSize[.02],Point[{{tfix,cv[tfix]},{tfix,trs[tfix]}}]}]},ImageSize->700],{tfix,0,2Pi,.001}]]

Module[{g=2{Cos[#],Sin[#],0}&,tau,b,n,cv,trs},
tau[t_]=tangent[g][t];
n[t_]=normal[g][t];
b[t_]=binormal[g][t];
cv[t_]=c[g][t];
trs[t_]=tor[g][t];
Manipulate[
GraphicsRow[{Show[{
ParametricPlot3D[g[t],{t,0,2Pi},Axes->None,PlotLabel->g[t]],
Graphics3D[{Sphere[g[tfix],0.04]}],
Graphics3D[{Red,Arrow[Tube[{g[tfix],g[tfix]+tau[tfix]},.01]],Green,Arrow[Tube[{g[tfix],g[tfix]+n[tfix]},.01]],Blue,Arrow[Tube[{g[tfix],g[tfix]+b[tfix]},.01]]}]
}],Plot[{cv[t],trs[t]},{t,0,2Pi},PlotRange->All,Epilog->{PointSize[.02],Point[{{tfix,cv[tfix]},{tfix,trs[tfix]}}]}]},ImageSize->700],{tfix,0,2Pi,.001}]]