5
$\begingroup$

This question already has an answer here:

I have this problem: I want to show the velocity vector Arrow[{pos, pos + vel}] with Manipulate

posicion = {ρ Cos[ω t],ρ Sin[ω t], a t};
velocidad = D[posicion, t];
aceleracion = D[velocidad, t];
parametros = {ρ -> 1, ω -> 1/2, a -> 1/5};
pos = posicion /. parametros;
vel = velocidad /. parametros;
ac = aceleracion /. parametros;
trayectoria = ParametricPlot3D[pos, {t, 0, 10 Pi}, PlotStyle -> Red];

Manipulate[Show[trayectoria, Graphics3D[Arrow[{pos, pos + vel}]]], {t, 0, 10 Pi}]

And appears this message:

Coordinate {Cos[0.5 CellContext't], Sin[0.5 CellContext't], 0.2 CellContext't} should be a triple of numbers, or a Scaled form.

I don't know what's the problem with the code.

$\endgroup$

marked as duplicate by Kuba, m_goldberg, Mr.Wizard Aug 14 '16 at 16:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

9
$\begingroup$

By defining your kinematics equations as top-level expressions (rather than as functions of the relevant quantities), you invite scoping problems. I recommend working with functions and making the Manipulate expression self-contained. Implementing that will simplify your work as well saving you worry about variable scoping issues. Here is how I would do it.

With[{ρ = 1, ω = 1/2, a = 1/5},
  Manipulate[
    Show[
      Graphics3D[
        {Thick, Arrow[{posicion[t], posicion[t] + velocidad[t]}]}], 
      ParametricPlot3D[posicion[u], {u, 0, 10 Pi}, PlotStyle -> Red],
      Boxed -> False],
    {t, 0, 10 Pi},
    Initialization :> (
      posicion[t_] := {ρ Cos[ω t], ρ Sin[ω t], a t}; 
      velocidad[t_] = D[posicion[t], t])]]

Short and simple, no?

demo

$\endgroup$
  • $\begingroup$ That's perfect! Thank you very much! $\endgroup$ – Gee45 Aug 24 '16 at 3:34
10
$\begingroup$

You can do it thus:

Manipulate[
 Show[trayectoria, 
  Graphics3D[Arrow[{pos, pos + vel} /. t -> α]]], {α, 0,
   10 Pi}]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you! but, why I have to change "t"? $\endgroup$ – Gee45 Aug 13 '16 at 21:36
  • $\begingroup$ @Gee45 becasue it would interfere with trayectoria $\endgroup$ – joojaa Aug 14 '16 at 7:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.