MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Graphics--combining graphics

  • To: mathgroup at
  • Subject: [mg66145] Re: [mg66108] Graphics--combining graphics
  • From: "David Park" <djmp at>
  • Date: Sun, 30 Apr 2006 04:22:24 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Are you looking for something like the following?


y[t_] := Piecewise[{{0, t <= 10}, {-(t - 10)^2/10, t > 10}}]

frame[s_] :=
    t = Max[0, Min[20, s]];
        {Red, Disk[{t, y[t]}, 0.2], Black, Circle[{t, y[t]}, 0.2],
          VanDykeBrown, Rectangle[{-0.2, -0.5}, {10, -0.2}]}],
      AspectRatio -> Automatic,
      PlotRange -> {{-1, 21}, {-11, 1}},
      ImageSize -> 400,
      Background -> Linen

Animate[frame[s], {s, -1, 21, 0.1}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime ->
      AnimationDirection -> Forward]}]

First I defined a frame for a time s. Then internally I defined a new time t
that was used in plotting the elements. In this case I simply used this
trick to pin t to a domain 0 to 20. When I animated the frames I used an s
range of -1 to 21. This provides a pause at the start and end of the
animation, which is very courteous to the viewer.

You can also use this trick of having a frame time s and an internal time t
to switch between various functions, or to provide pauses in the middle of
an animation. For example, on the Mathematica page at my web site you will
see an animation of two different rotation sequences of a book. Pauses were
introduced between each leg of the rotation sequence and, of course,
different functions were used to produce each leg of the sequence.

David Park
djmp at

From: spepperchin at [mailto:spepperchin at]
To: mathgroup at

I am trying to create an animation of a piecewise function.  I have a graph
of a ball rolling and I would like to combine an animation for one equation
of motion for the first part with another equation for the second part of
the motion.  It is easy enough to create the two animations individually,
however I am stumped on how to combine them into one continuous animation.

Link to the forum page for this post:
Posted through [[postId=10007]]

  • Prev by Date: Re: Why D[x', x] isn't 0 ?
  • Next by Date: Re: "In progress" saving of data collected using Reap/Sow
  • Previous by thread: Re: Graphics--combining graphics
  • Next by thread: Conditions with Statistical Functions