Message Boards Message Boards

1
|
1412 Views
|
3 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Controlling the image position during rotate and animate

Posted 11 years ago
Hi, I want to animate the rotation of a generated plot but have the (0,0) point of the plot stay stationary during the animation. Is there a way to do this? In what I have tried the resultig graphic is always left justified to its boundingbox and this results in the animation bouncing sideways for each corner of the plot.

Here is what I'm trying to develop. It's a simulation of the coriolis effect, the plot is the particle's trajectory in the rotating co-ordinate system and I want to rotate the entire plot so that you would see it in the non-rotating co-ordinate system. So the animation should produce a particle moving in a straight line on the notebook but following the loops and spirals of the plotted trajectory on the graph:
 cor[tt_] := Show[{
    ParametricPlot[{1/
        2 E^(-I t \[Omega]) (x0 + E^(2 I t \[Omega]) x0 + I y0 -
          I E^(2 I t \[Omega]) y0 + I t x0 \[Omega] -
          I E^(2 I t \[Omega]) t x0 \[Omega] - t y0 \[Omega] -
          E^(2 I t \[Omega]) t y0 \[Omega] + t v0 Cos[\[Theta]0] +
          E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
          I t v0 Sin[\[Theta]0] -
          I E^(2 I t \[Omega]) t v0 Sin[\[Theta]0]),
      1/2 E^(-I t \[Omega]) (-I x0 + I E^(2 I t \[Omega]) x0 + y0 +
         E^(2 I t \[Omega]) y0 + t x0 \[Omega] +
         E^(2 I t \[Omega]) t x0 \[Omega] + I t y0 \[Omega] -
         I E^(2 I t \[Omega]) t y0 \[Omega] - I t v0 Cos[\[Theta]0] +
         I E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
         t v0 Sin[\[Theta]0] +
         E^(2 I t \[Omega]) t v0 Sin[\[Theta]0])} /. {\[Omega] ->
       0.355, v0 -> 2.75, \[Theta]0 -> 2.15, x0 -> -5.9,
      y0 -> -4.8}, {t, 0, 60}, PlotRange -> {{-10, 10}, {-10, 10}},
    Frame -> False, AspectRatio -> 1, BaselinePosition -> Center],
   Graphics[
    Disk[{1/2 E^(-I t \[Omega]) (x0 + E^(2 I t \[Omega]) x0 + I y0 -
           I E^(2 I t \[Omega]) y0 + I t x0 \[Omega] -
           I E^(2 I t \[Omega]) t x0 \[Omega] - t y0 \[Omega] -
           E^(2 I t \[Omega]) t y0 \[Omega] + t v0 Cos[\[Theta]0] +
           E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
           I t v0 Sin[\[Theta]0] -
           I E^(2 I t \[Omega]) t v0 Sin[\[Theta]0]),
        1/2 E^(-I t \[Omega]) (-I x0 + I E^(2 I t \[Omega]) x0 + y0 +
           E^(2 I t \[Omega]) y0 + t x0 \[Omega] +
           E^(2 I t \[Omega]) t x0 \[Omega] + I t y0 \[Omega] -
           I E^(2 I t \[Omega]) t y0 \[Omega] -
           I t v0 Cos[\[Theta]0] +
           I E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
           t v0 Sin[\[Theta]0] +
           E^(2 I t \[Omega]) t v0 Sin[\[Theta]0])} /. {\[Omega] ->
         0.355, v0 -> 2.75, \[Theta]0 -> 2.15, x0 -> -5.9,
        y0 -> -4.8} /. t -> tt, .4]]
   }]
Animate[Rotate[cor[t], \[Omega] t /. \[Omega] -> 0.355, {0, 0}], {t,
  0, 60}, DefaultDuration -> 15]
POSTED BY: Alexei Gilchrist
3 Replies
Wow, this is really great, Alexei! Have you thought about making a Demonstration from it? Here are some examples.
POSTED BY: Vitaliy Kaurov
Awesome! Thanks Vitaliy.

Here is some further refinements:
 Manipulate[
  pos[t_] := {1/
      2 E^(-I t \[Omega]) (x0 + E^(2 I t \[Omega]) x0 + I y0 -
       I E^(2 I t \[Omega]) y0 + I t x0 \[Omega] -
       I E^(2 I t \[Omega]) t x0 \[Omega] - t y0 \[Omega] -
       E^(2 I t \[Omega]) t y0 \[Omega] + t v0 Cos[\[Theta]0] +
       E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] + I t v0 Sin[\[Theta]0] -
        I E^(2 I t \[Omega]) t v0 Sin[\[Theta]0]),
    1/2 E^(-I t \[Omega]) (-I x0 + I E^(2 I t \[Omega]) x0 + y0 +
      E^(2 I t \[Omega]) y0 + t x0 \[Omega] +
      E^(2 I t \[Omega]) t x0 \[Omega] + I t y0 \[Omega] -
      I E^(2 I t \[Omega]) t y0 \[Omega] - I t v0 Cos[\[Theta]0] +
      I E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] + t v0 Sin[\[Theta]0] +
       E^(2 I t \[Omega]) t v0 Sin[\[Theta]0])};
cor2[tt_] := {ParametricPlot[pos[t], {t, 0, 60}, PlotPoints -> 30,
     PlotStyle -> Directive[Thickness[.01], Orange]][[1]],
   Disk[pos[tt], .4],
   Arrow[{{0, -10}, {0, 10}}], Text[Style[y, Large], {1, 9}],
   Arrow[{{-10, 0}, {10, 0}}], Text[Style[x, Large], {9, -1}]};
Graphics[{Rotate[cor2[t], \[Omega] t, {0, 0}], Dashed,
   Line[{{x0,
      y0}, {pos[60][[1]] Cos[\[Omega] 60] -
       pos[60][[2]] Sin[\[Omega] 60],
      pos[60][[1]] Sin[\[Omega] 60] +
       pos[60][[2]] Cos[\[Omega] 60]}}]}, PlotRange -> 10],
{{\[Omega], 0.355}, 0, 1}, {{v0, 2.75}, 0, 5}, {{\[Theta]0, 2.15}, 0,
   2 \[Pi]}, {{x0, -5.9}, -10, 10}, {{y0, -4.8}, -10, 10}, {t, 0, 60}]
POSTED BY: Alexei Gilchrist
A very nice visualization. I think the trick here is to rotate the object where you have control of PlotRange. I suggest to make your original function to produce the pre-Graphics objects, so later you can wrap Rotate in Graphics and specify PlotRange.
 cor[tt_] := {ParametricPlot[{1/
          2 E^(-I t \[Omega]) (x0 + E^(2 I t \[Omega]) x0 + I y0 -
           I E^(2 I t \[Omega]) y0 + I t x0 \[Omega] -
           I E^(2 I t \[Omega]) t x0 \[Omega] - t y0 \[Omega] -
           E^(2 I t \[Omega]) t y0 \[Omega] + t v0 Cos[\[Theta]0] +
           E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
           I t v0 Sin[\[Theta]0] -
           I E^(2 I t \[Omega]) t v0 Sin[\[Theta]0]),
        1/2 E^(-I t \[Omega]) (-I x0 + I E^(2 I t \[Omega]) x0 + y0 +
          E^(2 I t \[Omega]) y0 + t x0 \[Omega] +
          E^(2 I t \[Omega]) t x0 \[Omega] + I t y0 \[Omega] -
          I E^(2 I t \[Omega]) t y0 \[Omega] - I t v0 Cos[\[Theta]0] +
           I E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
          t v0 Sin[\[Theta]0] +
          E^(2 I t \[Omega]) t v0 Sin[\[Theta]0])} /. {\[Omega] ->
        0.355, v0 -> 2.75, \[Theta]0 -> 2.15, x0 -> -5.9,
       y0 -> -4.8}, {t, 0, 60},
     PlotStyle -> Directive[Thickness[.01], Orange]][[1]],
   Disk[{1/2 E^(-I t \[Omega]) (x0 + E^(2 I t \[Omega]) x0 + I y0 -
          I E^(2 I t \[Omega]) y0 + I t x0 \[Omega] -
          I E^(2 I t \[Omega]) t x0 \[Omega] - t y0 \[Omega] -
          E^(2 I t \[Omega]) t y0 \[Omega] + t v0 Cos[\[Theta]0] +
          E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
          I t v0 Sin[\[Theta]0] -
          I E^(2 I t \[Omega]) t v0 Sin[\[Theta]0]),
       1/2 E^(-I t \[Omega]) (-I x0 + I E^(2 I t \[Omega]) x0 + y0 +
          E^(2 I t \[Omega]) y0 + t x0 \[Omega] +
          E^(2 I t \[Omega]) t x0 \[Omega] + I t y0 \[Omega] -
          I E^(2 I t \[Omega]) t y0 \[Omega] - I t v0 Cos[\[Theta]0] +
           I E^(2 I t \[Omega]) t v0 Cos[\[Theta]0] +
          t v0 Sin[\[Theta]0] +
          E^(2 I t \[Omega]) t v0 Sin[\[Theta]0])} /. {\[Omega] ->
        0.355, v0 -> 2.75, \[Theta]0 -> 2.15, x0 -> -5.9,
       y0 -> -4.8} /. t -> tt, .4]};
Animate[Graphics[
  Rotate[cor[t], \[Omega] t /. \[Omega] -> 0.355, {0, 0}],
  PlotRange -> 10], {t, 0, 60}, DefaultDuration -> 15]

POSTED BY: Vitaliy Kaurov
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