Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Implementing a method' topicStudent Support Forum > General > "Implementing a method"

Next Comment >Help | Reply To Topic
Author Comment/Response
Derek
11/27/11 12:19pm

Hello, I am trying to implement the following Osculating circle code into the Frenet Frames code below. I've been having a bit of trouble, it seems that thecircle is the method I need to implement from the Osculating circle code but each time I try I receive a strange error, it looks like I am not feeding it the right kind of data type or something. I'm trying to make it so that the osculating circle is graphed along with the frenet frame as the t slider is moved. Any help implementing the osculating circle code onto the freenet frames code would be highly appreciated!

http://demonstrations.wolfram.com/FrenetFrame/
http://demonstrations.wolfram.com/OsculatingCircles3D/


*****FREENET FRAME CODE*****

Manipulate[
W1 = Round[
Norm[Nr[t]] Norm[Derivative[1][r][t]] (
r[t][[1]] Bn[t][[1]] + r[t][[2]] Bn[t][[2]] +
r[t][[3]] Bn[t][[3]]), 0.1]; {a1, b1, c1} =
Round[Norm[Nr[t]] Norm[Derivative[1][r][t]] Bn[t], 0.1];
If[ a1 != 0, {A1, B1, C1, w1} =
Round[ {a1, b1, c1, W1}/a1, 0.1] ,
If[ b1 != 0, {A1, B1, C1, w1} =
Round[ {a1, b1, c1, W1}/b1 , 0.1] , {A1, B1, C1, w1} =
Round[ {a1, b1, c1, W1}/c1, 0.1]]];
W2 = Round[
Norm[Nr[t]] (
r[t][[1]] Nr[t][[1]] + r[t][[2]] Nr[t][[2]] +
r[t][[3]] Nr[t][[3]]), 0.1];
{a2, b2, c2} = Round[Norm[Nr[t]] Nr[t], 0.1];
If[ a2 != 0, {A2, B2, C2, w2} =
Round[ {a2, b2, c2, W2}/a2, 0.1] ,
If[ b2 != 0, {A2, B2, C2, w2} =
Round[ {a2, b2, c2, W2}/b2 , 0.1] , {A2, B2, C2, w2} =
Round[ {a2, b2, c2, W2}/c2, 0.1]]];
W3 = Round[
Norm[Derivative[1][r][t]] (
r[t][[1]] Tn[t][[1]] + r[t][[2]] Tn[t][[2]] +
r[t][[3]] Tn[t][[3]]), 0.1];
{a3, b3, c3} = Round[Norm[Derivative[1][r][t]] Tn[t], 0.1];
If[ a3 != 0, {A3, B3, C3, w3} =
Round[ {a3, b3, c3, W3}/a3, 0.1] ,
If[ b3 != 0, {A3, B3, C3, w3} =
Round[ {a3, b3, c3, W3}/b3 , 0.1] , {A3, B3, C3, w3} =
Round[ {a3, b3, c3, W3}/c3, 0.1]]];

Grid[{{Text@Column[{
Row[{Style["r", Italic], "(", Style["t", Italic], ") = {sin(",
Style["t", Italic], "), cos(", Style["t", Italic], "), ",
Style["t", Italic], "}"}],
Labeled[ Framed[ Round[ Tn[t], 0.1]],
Style[ "unit tangent", RGBColor[.6, .73, .36], Bold], Top ],
Labeled[ Framed[Round[ Nr[t], 0.1]],
Style[ "unit normal", RGBColor[1, .47, 0], Bold], Top ],
Labeled[ Framed[Round[ Bn[t], 0.1]],
Style[ "binormal", ColorData["HTML", "SlateBlue"], Bold],
Top ],
Row[{Style[ "osculating ", RGBColor[.6, .73, .36], Bold],
Style[ "plane ", RGBColor[1, .47, 0], Bold]}],
Framed[Row[ {A1, Style["x", Italic], "+", B1,
Style["y", Italic], "+", C1, Style["z", Italic], " = ",
w1 }]] ,
Row[{Style["rectifying ", RGBColor[.6, .73, .36], Bold],
Style["plane", ColorData["HTML", "SlateBlue"], Bold]}],
Framed[Row[ { A2, Style["x", Italic], "+", B2,
Style["y", Italic], "+", C2, Style["z", Italic], " = ",
w2 }]],
Row[{Style[ "normal " , ColorData["HTML", "SlateBlue"],
Bold], Style[ "plane ", RGBColor[1, .47, 0], Bold]}],
Framed[Row[{ A3, Style["x", Italic], "+", B3,
Style["y", Italic], "+", C3, Style["z", Italic], " = ",
w3 }]]
}, Center],
Show[
ParametricPlot3D[r[s], {s, 0, 2 \[Pi] },
PlotStyle -> {Cyan, Tube[dia]},
PlotRange -> {{-2, 2}, {-2, 2}, {-2, 8}}],
ParametricPlot3D[
Tooltip[OscPl[u, v, t], "osculating" ], {u, 0, size}, {v, 0,
size}, PerformanceGoal -> ControlActive["Speed", "Quality"],
PlotRange -> {{-2, 2}, {-2, 2}, {-2, 8}} ],
ParametricPlot3D[
Tooltip[RecPl[u, v, t], "rectifying"], {u, 0, size}, {v, 0,
size}, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 8}} ],
ParametricPlot3D[
Tooltip[NorPl[u, v, t], "binormal"], {u, 0, size}, {v, 0,
size}, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 8}} ],
VectorFieldPlots`ListVectorFieldPlot3D[{{r[t], 2 size*Tn[t]}},
VectorHeads -> True,
ColorFunction -> (RGBColor[.6, .73, .36] &)],
VectorFieldPlots`ListVectorFieldPlot3D[{{r[t], 2 size*Nr[t]}},
VectorHeads -> True, ColorFunction -> (RGBColor[1, .47, 0] &)],
VectorFieldPlots`ListVectorFieldPlot3D[{{r[t], 2 size*Bn[t]}},
VectorHeads -> True,
ColorFunction -> (ColorData["HTML", "SlateBlue"] &)],
ImageSize -> {440, 370}]}},
ItemSize -> {{12, Automatic}, Automatic}],

{{t, 0}, 0, 2 \[Pi] , .1},
{{size, 1.3, "scale"}, 0.5, 2, .2},
{{dia, 0.03, "tube"}, 0.01, 0.5},

TrackedSymbols -> Manipulate,
Initialization :> {
Get["VectorFieldPlots`"];
r[s_] := {Sin[s], Cos[s], s};
Tn[s_] := {Cos[s]/Sqrt[2], -(Sin[s]/Sqrt[2]), 1/Sqrt[2]} ;
Nr[s_] := {-Sin[s], -Cos[s], 0} ;
Bn[s_] := {Cos[s]/Sqrt[2], -(Sin[s]/Sqrt[2]), -(1/Sqrt[2])} ;
OscPl[p_, h_, s_] := {(p Cos[s])/Sqrt[2] + Sin[s] - h Sin[s],
Cos[s] - h Cos[s] - (p Sin[s])/Sqrt[2], p/Sqrt[2] + s} ;
RecPl[p_, h_,
s_] := {(h Cos[s])/Sqrt[2] + (p Cos[s])/Sqrt[2] + Sin[s],
Cos[s] - (h Sin[s])/Sqrt[2] - (p Sin[s])/Sqrt[2], -(h/Sqrt[2]) +
p/Sqrt[2] + s} ;
NorPl[p_, h_, s_] := {(h Cos[s])/Sqrt[2] + Sin[s] - p Sin[s],
Cos[s] - p Cos[s] - (h Sin[s])/Sqrt[2], -(h/Sqrt[2]) + s} ;
}]






***OSCULATING CIRCLE CODE***
Manipulate[

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

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

tmin = 0; tmax = 2 Pi;

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, 2 Pi}, 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 = 2 Pi}]

URL: ,

Subject (listing for 'Implementing a method')
Author Date Posted
Implementing a method Derek 11/27/11 12:19pm
Re: Implementing a method Bill 11/29/11 1:36pm
Re: Re: Implementing a method Derek 11/29/11 5:45pm
Next Comment >Help | Reply To Topic