Osculating Circles 3D

Manipulate[

Module[{r,tmin,tmax,Mag,curvature,radius,T,Tprime,NNN,B,thecircle},

r[t_]=Switch[fcn,
1,{5Cos[t],5Sin[t],5Sin[3t]},
2,{5*Cos[3t],5*Sin[3t],3(t-Pi)},
3,{5*Cos[3t],3*Sin[3t],3(t-Pi)}];

tmin=0; tmax=2Pi;

Mag[w_]=Sqrt[w.w];

curvature[t_]=Mag[Cross[D[r[t],t],D[D[r[t],t],t]]]/
Mag[D[r[t],t]]^3;

radius[t_]=If[curvature[t]==0,9999,
1/curvature[t]];

T[t_]=D[r[t],t]/Sqrt[D[r[t],t].D[r[t],t]];
Tprime[t_]=D[T[t],t];
NNN[t_]=If[Tprime[m]=={0,0},{0,0},Tprime[m]/Sqrt[Tprime[m].Tprime[m]]];
B[t_]=Cross[T[t],NNN[t]];

thecircle[t0_]:=Module[{},

transMat=Transpose[{T[t0],NNN[t0],B[t0]}];

center1=radius[t0]*NNN[t0]+r[t0];
xc=center1[[1]];
yc=center1[[2]];
zc=center1[[3]];

 circle1[r_]:={r*Cos[t],r*Sin[t],0};

graphthis=transMat.circle1[radius[t0]]+{xc,yc,zc};

ParametricPlot3D[graphthis,{t,0,2Pi},MaxRecursion->0,PlotStyle->Purple]

]; (* End Module *)

Show[ParametricPlot3D[r[t],{t,tmin,tmax},PerformanceGoal->"Quality"],
 thecircle[m],Graphics3D[{PointSize[0.02],Point[r[m]]}],
AspectRatio->Automatic,ImageSize->{500,375},PlotRange->25,Boxed->False,Axes->False,SphericalRegion->True,ViewAngle->.14]

],
{{fcn,1,"curve"},{1->"sine circle",2->"circular helix",3->"elliptic helix"},ControlType->RadioButtonBar},
{{m,tmin,"position on curve"},tmin,tmax},TrackedSymbols:>{m,fcn}, Initialization:>{tmin=0;tmax=2Pi}]

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Osculating Circles 3D" from The Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/OsculatingCircles3D/

Contributed by: Abby Brown

A full-function Wolfram Mathematica 6 system is required to edit this notebook.
GET WOLFRAM MATHEMATICA 6 »

© The Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »