Application Center - Maplesoft

App Preview:

Classroom Tips and Techniques: Animated Trace of a Curve Drawn by Radius Vector

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application




 

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

NULL

A plane curve R(t) = x(t)*i+y(t)*j is traced by a "moving" radius vector R(t). Code for this animation is explored in this article.

 

In particular, consider the animated tracing of the curve R(t) = (t^2-2)*i+(t+1)*j, 0 <= t and t <= 5, 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 R(t)

 

In Figure 1, the tip of the radius vector traces the plane curve R(t) and along this trace, the green dots mark the points where t = k, k = 0, 1, () .. (), 5. 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.

NULL

Method 1

NULL

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

restart

Loading plots  

Loading VectorCalculus

• 

Define the curve via the PositionVector command.

R := PositionVector([t^2-2*t, t+1])

• 

The PlotPositionVector command draws a curve defined as by the PositionVector command. Applying the animate command produces the animated tracing of the curve.

p[1] := animate(PlotPositionVector, [R, 0 .. z], z = 0 .. 5, frames = 101)

• 

The PlotVector command draws an arrow from the origin to the point R(t). 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!

p[2] := animate(PlotVector, [R, width = .2, color = red, transparency = .8, head_length = .7], t = 0 .. 5, frames = 101)

• 

The plot command re-draws the curve R(t) 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.

p[3] := animate(plot, [[convert(R, list)], style = point, symbol = solidcircle, symbolsize = 15, color = green], t = 0 .. 5, frames = 101, trace = 5)

• 

Three separate animations are merged into a single animation by the display command.

display(p[1], p[2], p[3], scaling = constrained)

Table 1   Annotated code for producing the animation in Figure 1

NULL

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.

NULL

Method 2

NULL

Table 2 contains alternate code for generating the animation in Figure 1. In essence, by modifying the call to the PlotPositionVector command, the animation p[3] in Table 1 is eliminated.

 

• 

Initialize by executing a restart.

• 

Tools_Load Package: Plots

• 

Tools_Load Package: Vector Calculus

restart

Loading plots  

Loading VectorCalculus

• 

Define the curve via the PositionVector command.

R := PositionVector([t^2-2*t, t+1])

• 

Define f, a function that generates a list of integers from 0 to the largest integer preceeding its argument, x.

f := proc (x) options operator, arrow; [seq(k, k = 0 .. floor(x))] end proc

• 

The PlotPositionVector command draws a curve defined as by the PositionVector command. Applying the animate command produces the animated tracing of the curve.

• 

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.

p[1] := animate(PlotPositionVector, [R, 0 .. z, points = ('f')(z), pointoptions = [symbolsize = 15, color = green]], z = 0 .. 5, frames = 101)

NULL

• 

The PlotVector command draws an arrow from the origin to the point R(t). The animate command generates an animation of the radius vector traversing the curve.

• 

Again, much of the syntax determines the look of the radius-vector arrow!

p[2] := animate(PlotVector, [R, width = .2, color = red, transparency = .8, head_length = .7], t = 0 .. 5, frames = 101)

• 

Two separate animations are merged into a single animation by the display command.

display(p[1], p[2], scaling = constrained)

Table 2   Alternate annotated code for producing the animation in Figure 1

NULL

The alternate coding in Table 2 eliminates the need to coordinate the number of frames with the trace option required by animation p[3] in Table 1.

NULL

Method 3

NULL

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.

 

F:=proc(z)  local p[1],p[2]:  p[1]:=PlotPositionVector(R,0..z,points=f(z),pointoptions=[symbolsize=15,color=green]):  p[2]:=PlotVector(eval(R,t=z),width=.2,color=red,transparency=.8,head_length=.7):  display(p[1],p[2],scaling=constrained):  end proc:

Table 3   Definition of F(z), a function that returns a single frame of the animation in Figure 1

 

Of course, the definition of f in Table 2, and of R(t) in Tables 1 and 2, are assumed prior to the execution of the code in Table 3. Once F(z) has been defined, the desired animation is produced by a call to the animate command, as shown below.

 

animate(F, [z], z = 0 .. 5, frames = 101)

NULL

``

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.