# Problem with combining Manipulate and ParametricPlot3D

I've beein trying to solve this problem but somehow I just can't combine Manipulate and ParametricPlot3D.

trobrid[g_, t_, a_, b_] := Module[{X, Y, Z, tang, norm, binorm, k, l},
g == {X[t], Y[t], Z[t]};
tang = D[g, t]/Simplify[Sqrt[D[g, t].D[g, t]]];
norm = D[tang, t]/Simplify[Sqrt[D[tang, t].D[tang, t]]];
binorm = FullSimplify[Cross[tang, norm], t > 0];
Manipulate[
ParametricPlot3D[g, {t, a, b}],
Graphics3D[{
Red, Arrow[{g, tang + g} /. {t -> s}],
Blue, Arrow[{g, norm + g} /. {t -> s}],
Purple, Arrow[{g, binorm + g} /. {t -> s}]
}], {s, a, b}]
]


This is the error:

## 1 Answer

Try this:

Clear[g, t, a, b, s, trobrid]
trobrid[g_, t_, a_, b_] := DynamicModule[
{X, Y, Z, tang, norm, binorm, k, l},
{X[t], Y[t], Z[t]} = g;
tang = D[g, t]/Simplify[Sqrt[D[g, t].D[g, t]]];
norm = D[tang, t]/Simplify[Sqrt[D[tang, t].D[tang, t]]];
binorm = FullSimplify[Cross[tang, norm], t > 0];

Manipulate[
Show[
ParametricPlot3D[g, {t, a, b}],
Graphics3D[
{Red, Arrow[{g, tang + g} /. {t -> s}], Blue,
Arrow[{g, norm + g} /. {t -> s}], Purple,
Arrow[{g, binorm + g} /. {t -> s}]}]
],
{s, a, b}
]
]


Then:

trobrid[{Cos[t], Sin[t], t/3}, t, 0, 3 Pi]


Issues in your original code:

1. You should use DynamicModule with Manipulate, rather than Module.
2. g == {X[t], Y[t], Z[t]}; is incorrect as an assignment; you really want to assign {X[t], Y[t], Z[t]} to the existing value of g, so you want {X[t], Y[t], Z[t]} = g, and you want to use Set (=), not Equal (==).
3. You need to wrap your graphics objects in Show within Manipulate to combine them and show them superimposed.
• Thank you very much. And what is the command if I want to show for example Torsion and Curvature at each point of the curve. How do I get that into the graphic? – zermelovac Mar 20 '16 at 21:55
• @zermelovac not sure, I haven't really parsed your code for function, just for syntactic correctness. The Frenet-Serret equations may be relevant to you; see previous questions on this site, and the docs for FrenetSerretSystem perhaps? – MarcoB Mar 20 '16 at 22:04
• Let me correct myself. How do I insert text inside a graphic, somewhere in the frame. – zermelovac Mar 20 '16 at 22:07
• @zermelovac Oh! I misunderstood; that's fortunately an easier task :-) Try adding this inside your Graphics3D list of objects within the Manipulate: Inset[Style["s = " <> ToString@Round[s, 0.1], 28, Black], Scaled[{0.3, 0.2, 0}]]. See how it works, then you can use it as a template of sorts to roll your own. – MarcoB Mar 20 '16 at 22:15