Message Boards Message Boards

0
|
5287 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Get animation of the tip of a vector moving along a parameterized 3D line?

Posted 8 years ago

Hello, I am trying to program an animation that does a very similar thing as an animation of a point moving along a line but instead of the point I need a vector originating from (0,0,0). This is how i got so far with a point:

path[var_] := CoordinateTransformData["Spherical" -> "Cartesian", "Mapping",
  {1, Exp[-15 (var - \[Pi]/2)^4] + Pi/4, 
   0.5 ArcTan[20 (var - \[Pi]/2)] + \[Pi]/4}]

Animate[
    Show[
  ParametricPlot3D[path@u, {u, 1/4 \[Pi], 3/4 Pi}, PlotStyle -> Gray, 
   Boxed -> False, Axes -> False],
        Graphics3D[{Red, PointSize[0.05], Point[path@v]}]], {v, 1/4 \[Pi],
   3/4 Pi}] 

thanks in advance for any suggestions. Stephan

POSTED BY: Stephan Brandt
2 Replies
Posted 8 years ago

Thank you. Worked perfectly.

POSTED BY: Stephan Brandt

This is rather simple. In the Graphics3D part add an arrow from the origin to the running point. Some modifications though.

  1. You calculate the path using the ParametricPlot3D for each point of the Animate function. Just compute it outside and use this computation. This is much faster.
  2. Removing the 3D Box make you lose the "3D" effect
  3. Sample the Animate with a better granularity

look at the attached code having these modifications

path[var_] := 
 CoordinateTransformData["Spherical" -> "Cartesian", 
  "Mapping", {1, Exp[-15 (var - \[Pi]/2)^4] + Pi/4, 
   0.5 ArcTan[20 (var - \[Pi]/2)] + \[Pi]/4}]

With[{g = 
   ParametricPlot3D[path@u, {u, 1/4 \[Pi], 3/4 Pi}, 
    PlotStyle -> Gray]}, 
 Animate[Show[g, 
   Graphics3D[{Arrow[{{0, 0, 0}, path[v]}], Red, PointSize[0.05], 
     Point[path@v]}]], {v, 1/4 \[Pi], 3/4 Pi, \[Pi]/50}]]

best

yehuda

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract