Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

RE: parametric plots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30008] RE: [mg29969] parametric plots
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 21 Jul 2001 00:49:15 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Richard,

Here is a short method to animate a ParametricPlot for the example of an
ellipse.

Needs["Graphics`Animation`"]
Needs["Graphics`Colors`"]

curve[t_] := {4Cos[t], 2Sin[t]}

frame[t_] :=
  ParametricPlot[curve[s] // Evaluate, {s, -0.00001, t}, Frame -> True,
    PlotRange -> {{-4.5, 4.5}, {-2.2, 2.2}}]

Animate[frame[t], {t, 0, 2 Pi}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]
FrontEndTokenExecute["SelectionAnimate"]

Some observations:
1) We have to explicitly specify the PlotRange so that the same one will be
used for each frame.
2) I started drawing the curve at a slightly negative value so that t = 0
will not generate an error message.
3) The extra statements after Animate are just a convenient method to
select, close up, and activate the animation cells.

Here is a way to make a fancier animation. It uses several routines I
mentioned a week or so ago on MathGroup, which I repeat here.

Attributes[DrawGraphics] = {HoldAll};
DrawGraphics[plot_] :=
  Block[{$DisplayFunction = Identity},
    First[Graphics[plot]]]

Draw2D[primitives_List, opts___?OptionQ] := Show[Graphics[primitives], opts]

Now in each frame I:
1) Draw the full curve in Pink on a Linen background.
2) Draw the partial curve in Black.
3) Put a Black point at the start and a Red point at the end of the partial
curve.
4) Add a Text statement giving the value of the parameter.

frame[t_] :=
  Draw2D[{Pink,
      DrawGraphics[ParametricPlot[Evaluate[curve[s]], {s, 0, 2 Pi}]], Black,
      AbsolutePointSize[4], Point[curve[0]],
      DrawGraphics[ParametricPlot[Evaluate[curve[s]], {s, -0.0001, t}]],
Red,
      Point[curve[t]], Black,
      Text["t = " NumberForm[N[t], {3, 2}], Scaled[{0.1, 0.1}], {-1, 0}]},
    Frame -> True, PlotRange -> {{-4.5, 4.5}, {-2.8, 2.2}},
    Background -> Linen, PlotLabel -> "ParametricPlot Animation",
    ImageSize -> 500]

Animate[frame[t], {t, 0, 2Pi}, Frames -> 40]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]
FrontEndTokenExecute["SelectionAnimate"

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/




 From: richard speers [mailto:rspeers at skidmore.edu]
To: mathgroup at smc.vnet.net
>
> This one is easy, I know, but I can't do it.  For classroom use I want
> to be able to watch a  parametric curve being drawn.
>
> Thanks.
>
> R. Speers
>
>



  • Prev by Date: Re: RE: notation help: f(x) = (sin x)^(1/3)
  • Next by Date: Re: [Q] Generalized Partitions
  • Previous by thread: Re: parametric plots
  • Next by thread: sort