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:

     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

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

enter image description here


Probably cleaner:

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

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

enter image description here

  • $\begingroup$ Very nice! This deserves the accept. $\endgroup$ – march Jun 19 '15 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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