6

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.

Feyre
  • 8,597
  • 2
  • 27
  • 46
Gee45
  • 75
  • 4

2 Answers2

10

You can do it thus:

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

enter image description here

Feyre
  • 8,597
  • 2
  • 27
  • 46
10

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

m_goldberg
  • 107,779
  • 16
  • 103
  • 257