0
$\begingroup$

I'm trying to animate a rotating arrow within a plot, and I'm seeing two issues I can't figure out how to resolve.

1) The arrow isn't originating from {0,0} as I have demanded.

2) The length of the arrow is changing as it rotates.

Animate[
 w0 = 1 - t;
 θ = π/2 - t π/2;
 Plot[{t, -t}, {z, -10, 10}, PlotRange -> {{-10, 10}, {-2, 2}}, 
  PlotStyle -> {Black, Black}, ImageSize -> Large,
  Epilog -> 
   Inset[Graphics[{Orange, Thick, Arrowheads[Large], 
      Arrow[{{0, 0}, {Cos[θ], Sin[θ]}}]}]]], {t, 0, 1}]

If I try to set the origin of the arrow instead to Scaled[{0,0}], the arrow doesn't rotate (and is still in the wrong place) unless I also scale the destination. Doing both of these, the arrow rotates but still not from the origin of the plotspace. Further, this is a problematic method since I also want to stretch the arrow (at the endpoint) as the animation runs further (excluded in the MWE).

Edit: MMA 11.3

$\endgroup$
2
$\begingroup$

Don't use Inset, since that disconnects the coordinates of the Arrow from the coordinates of the Plot:

Animate[
    w0 = 1-t;
    θ = π/2-t π/2;
    Plot[
        {t,-t},
        {z,-10,10},
        PlotRange->{{-10,10},{-2,2}},
        PlotStyle->{Black,Black},
        ImageSize->Large,
        Epilog->{Orange,Thick,Arrowheads[Large],Arrow[{{0,0},{Cos[θ],Sin[θ]}}]}
    ],
    {t,0,1}
]
$\endgroup$
  • $\begingroup$ Nailed it, thanks. $\endgroup$ – avikarto Mar 15 '18 at 16:01

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.