TNB Frames

Code

frames[tValue_,deriv_,second_,showT_,showN_,showB_,normal_,osculating_]:=(d[t_]:=r'[t];
v1=r[tValue];
v2 = r'[tValue];
v3 = r''[tValue];
unitDeriv[t_]=d[t]/Sqrt[d[t][[1]]^2+d[t][[2]]^2+d[t][[3]]^2];
vT=unitDeriv[tValue];
vN=N[Normalize[unitDeriv'[tValue]]];
vB=Cross[vT,vN];
point={Blue,PointSize[0.02],Point[v1]};
derivArrow=If[deriv,{Blue,Arrowheads[.02],Thickness[0.005],Arrow[{v1,v1+v2}]},{}];
secondDerivArrow=If[deriv,{Red,Arrowheads[.02],Thickness[0.005],Arrow[{v1,v1+v3}]},{}];
TArrow=If[showT,{Blue,Arrowheads[.02],Thickness[0.005],Arrow[{v1,v1+vT}]},{}];
NArrow=If[showN,{Red,Arrowheads[.02],Thickness[0.005],Arrow[{v1,v1+vN}]},{}];
BArrow=If[showB,{Green,Arrowheads[.02],Thickness[0.005],Arrow[{v1,v1+vB}]},{}];
normalPlane=If[normal,ContourPlot3D[vT.({x,y,z}-v1)==0,{x,v1[[1]]-.5,v1[[1]]+.5},{y,v1[[2]]-.5,v1[[2]]+.5},{z,v1[[3]]-.5,v1[[3]]+.5},ContourStyle->{LightBlue,Opacity[0.8]},Mesh->None],{}];
osculatingPlane=If[osculating,ContourPlot3D[vB.({x,y,z}-v1)==0,{x,v1[[1]]-.5,v1[[1]]+.5},{y,v1[[2]]-.5,v1[[2]]+.5},{z,v1[[3]]-.5,v1[[3]]+.5},ContourStyle->{LightGreen,Opacity[0.8]},Mesh->None],{}];
Show[Graphics3D[{point,derivArrow,secondDerivArrow,TArrow,NArrow,BArrow,Text[x,{3.2,0,0}],Text[y,{0,3.2,0}],Text[z,{0,0,3.2}]}],ParametricPlot3D[r[s],{s,0,4 Pi},PlotStyle->{Orange,Thickness[0.008]}],normalPlane,osculatingPlane,Axes->True,AxesOrigin->{0,0,0},PlotRange->{{-3,3},{-3,3},{-3,3}},Boxed->False,ViewPoint->{2000,400,800},Lighting->{{"Ambient",White}}])

Graphics

r[t_]:={Cos[t],0.5Sin[2 t],0.4t};
showDeriv = False;
showSecondDeriv = False;
showT = True;
showN = True;
showB = True;
showNormalPlane=True;
showOsculatingPlane=True;

Animate[frames[t,showDeriv,showSecondDeriv,showT,showN,showB,showNormalPlane,showOsculatingPlane],{t,0,2Pi}]