Classroom Tips and Techniques: Animated Trace of a Curve Drawn by Radius Vector
Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow
Maplesoft
Introduction
A plane curve is traced by a "moving" radius vector . Code for this animation is explored in this article.
In particular, consider the animated tracing of the curve , , shown in Figure 1.
R := VectorCalculus:-PositionVector([t^2-2*t,t+1]):
p1 := plots:-animate(VectorCalculus:-PlotPositionVector,[R,0..z],z=0..5,frames=101):
p2 := plots:-animate(VectorCalculus:-PlotVector,[R,width=.2,color=red,transparency=.8,head_length=.7],t=0..5,frames=101):
p3 := plots:-animate(plot,[[convert(R,list)],style=point,symbol=solidcircle,symbolsize=15,color=green],t=0..5,frames=101,trace=5):
plots:-display(p1,p2,p3,scaling=constrained);
Figure 1 Animation of the radius-vector tracing of
In Figure 1, the tip of the radius vector traces the plane curve and along this trace, the green dots mark the points where . The code for generating this animation is hidden inside the table containing the figure, and can be exposed by selecting "Properties" from the Table menu, and selecting "Show input" in the resulting dialog. This code, and two alternate versions, is described below.
Method 1
Table 1 contains code equivalent to that which generated the animation in Figure 1. By loading the plots and VectorCalculus packages, the short form of the relevant commands from those packages can be used.
Initialize by executing a restart.
Tools_Load Package: Plots
Tools_Load Package: Vector Calculus
Loading plots
Loading VectorCalculus
Define the curve via the PositionVector command.
The PlotPositionVector command draws a curve defined as by the PositionVector command. Applying the animate command produces the animated tracing of the curve.
The PlotVector command draws an arrow from the origin to the point . The animate command generates an animation of the radius vector traversing the curve.
Note that much of the syntax here determines the look of the radius-vector arrow!
The plot command re-draws the curve but as a sequence of points. The trace option in the animate command determines the number of equispaced frames that are displayed.
Note that much of the syntax here determines the look of the plotted points.
Three separate animations are merged into a single animation by the display command.
Table 1 Annotated code for producing the animation in Figure 1
Of course, the number of frames in each of the three animations has to agree so that the frames are synchronized.
However, the PlotPositionVector command takes a points option that specifies the location of points to be graphed. The third animation could be avoided by a successful implementation of this points option. This is done in Method 2, below.
Method 2
Table 2 contains alternate code for generating the animation in Figure 1. In essence, by modifying the call to the PlotPositionVector command, the animation in Table 1 is eliminated.
Define , a function that generates a list of integers from 0 to the largest integer preceeding its argument, .
Include the points option; the list of points grows as the parameter along the curve increases.
Again, much of the syntax determines the look of the points being graphed.
Again, much of the syntax determines the look of the radius-vector arrow!
Two separate animations are merged into a single animation by the display command.
Table 2 Alternate annotated code for producing the animation in Figure 1
The alternate coding in Table 2 eliminates the need to coordinate the number of frames with the trace option required by animation in Table 1.
Method 3
A third way to generate the animation in Figure 1 is to animate a procedure whose return is a single frame of the desired animation. Such a function is defined in Table 3.
Table 3 Definition of , a function that returns a single frame of the animation in Figure 1
Of course, the definition of in Table 2, and of in Tables 1 and 2, are assumed prior to the execution of the code in Table 3. Once has been defined, the desired animation is produced by a call to the animate command, as shown below.
Legal Notice: © Maplesoft, a division of Waterloo Maple Inc. 2013. Maplesoft and Maple are trademarks of Waterloo Maple Inc. This application may contain errors and Maplesoft is not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact Maplesoft for permission if you wish to use this application in for-profit activities.