# Create a moving plot along a parametric plot using Manipulate?

I have been looking through Manipulate examples and haven't been able to create a working plot yet. I have a parametric plot defined:

Clear[f,x,y,t, surfaceplot]
{x[t_], y[t_]} = (t/2) {Cos[t], Sin[t]};
f[x_, y_] = 2 E^(-x^2 - y^2);
surfaceplot2 = Plot3D[f[x, y], {x, 0, 6Pi}, {y, 0, 6Pi}, AxesLabel -> {"x", "y", "z"}];


I am trying to create a point that moves along the plot from 0 to 6Pi using manipulate. I'm trying to adapt this code:

 Manipulate[
ParametricPlot3D[ {x[t], y[t], f[x[t],y[t]]}, {t, 0, 6Pi},
PerformanceGoal -> "Quality",
Epilog -> {Red, PointSize -> .05, Point[{x[t],y[t] }]}],
{{anotherT, 0}, 0, 6 Pi, Pi/64} ]


Does anyone have any thoughts on how to do this?

That won't work because Epilog yields 2D graphics primitives, so you can't have plot a moving 3D point using Epilog. Instead, make a separate Graphics3D object and Show both of them. So, for instance defining

parPlot = ParametricPlot3D[
{x[t], y[t], f[x[t], y[t]]}
, {t, 0, 6 Pi}
, PlotRange -> All
, PerformanceGoal -> "Quality"
];


we can make

Manipulate[
Show[
parPlot
, Graphics3D[ {Red, PointSize -> 0.02, Point[{x[tp], y[tp], f[x[tp], y[tp]]}] } ]
]
, {tp, 0, 6 Pi, Pi/64}
]


Probably cleaner:

f[x_, y_] := 2 E^(-x^2 - y^2);
pos[t_] := {##, f@##} & @@ (t/8 {Cos[t], Sin[t]})

Manipulate[
Show[
Plot3D[f[x, y], {x, -Pi, Pi}, {y, -Pi, Pi}, PlotRange -> All,
Mesh -> None, PlotStyle -> [email protected], Boxed -> False],
ParametricPlot3D[pos@t, {t, 0, 6 Pi}],
Graphics3D@{Red, PointSize -> .05, Point@pos@t}],
{t, 0, 6 Pi}]


• Very nice! This deserves the accept. Commented Jun 19, 2015 at 16:34