Example 06
Two Dimensional Parametric Plots
and Graphics Primitives

Copyright „ 1993 by Bill Titus, Carleton College, 
Department of Physics and Astronomy, Northfield, MN  55057-4025
September 6, 1993

Topics and Skills

1.  ParametricPlot[].
2.  The MMA constant  Degree.
3.  Two dimensional graphics primitives, including global and local options.
4.  Removing input and output stored in memory.

Problem

A place-kicker in the Carleton - St. Olaf football game is located  40 m  from the goal post.  The horizontal bar for the goal post is  3.0 m  above the ground.  The football is kicked with an initial speed of  vo = 25 m/s  at an angle of  a  equal to  30∞  with respect to the ground.  Does the football clear the bar?

In terms of a coordinate system whose origin is at the launch site and whose x-axis is horizontal and y-axis is vertical, the relevant equations are

x[t] = vx[0]t
	 y[t] = vy[0]t - (1/2)gt2

where

vx[0] = vo cos[a]  
  vy[0] = vo sin[a].

Find out whether the football clears the bar by plotting the trajectory of the football on a x-y graph using the parametric representation  x[t]  and  y[t].

Solution

Step 1 - Complete the code below which uses  Set[]  to create the projectile equations for  x[t]  and  y[t]  as functions of  t,  vo,  angle,  and  g.

Clear[vo, angle, g, t, x, y]
x[vo_, angle_, t_, g_] = 
y[vo_, angle_, t_, g_] =

Comment 1

1.  Was it necessary to use all four variables as arguments in the functions?

Step 2 - Check your functions by finding the values for  x  and  y  when  t = 1.0 s, using the initial conditions specified in the problem.  You may find the MMA constant  Degree  useful.

Comment 2

1.  Did you get help on  Degree?  If not, do so.
2.  In order to force a numerical evaluation, you can use   N[] to calculate the numerical value of the angle.
3.  What are the advantages and disadvantages of inserting numbers directly as the arguments of a function versus setting symbols equal to the numerical results and then inserting the symbols as the arguments of a function?

Step 3 - Now you want to plot  x[t]  versus  y[t].  To do so, find out information on the MMA function   ParametricPlot[].

Comment 3

1.  How do these options compare with those in  Plot[]?

Step 4 - Plot the desired trajectory, but for now don't include any options.

Step 5 - Add options to your plot so that the projectile is not shown entering the earth.  Also label your axes and title the plot.  Finally name the graphics object  plot1  so you can refer to it latter.

Comment 5

1.  Note the importance of lines and indents to make your code readable.
2.  You can use  PlotRange  to cut off the trajectory below ground.
3.  What if you want to add the goal post to the graph and label it.  You can do this within MMA using "graphics primitives".

Step 6 - Start by finding out about MMA's  InputForm[]  and then apply this function to  plot1.  Describe what you see.

Comment 6

1.  You should see a  Line[]  command followed by a list of points and then various options, all embedded in the command  Graphics[].  Get help of the command  Graphics[].
2.  ParametricPlot[] is thus a short hand notation for producing graphics objects which are then displayed using  Show[].
3.  To plot graphics primitives one uses the format   
          Show[Graphics[{primitives}, {global options}]].
4.  There are eight graphics primitives:  Point,  Line,  Circle,  Disk,  Rectangle,  Polygon,  Text,  and  Raster.
5.  The global options are those in  Plot[] or  ParametricPlot[],  minus the curve enhancing ones.  
6.  The local options are the graphics directives; they go before graphics primitives and affect all that follows.

Step 7 - Look over the following code.  Try to guess the object that will be produced.  Then activate the cell and describe what you see.

Clear[myGraphics]
myGraphics =
   Graphics[
     {RGBColor[0, 0, 1],
      Circle[{0, 0}, 1],
      Circle[{0, 0}, 0.7, {Pi, 2Pi}],
      RGBColor[1, 0, 0],
      Disk[{-0.5, 0.5}, 0.1],
      Disk[{0.5, 0.5}, 0.1],
      RGBColor[0, 1, 0],
      Line[{{-0.2, -0.2}, {0.0, 0.2}, {0.2, -0.2}}],
      RGBColor[0, 0, 0],
      Text[FontForm["I'm pleased with myself",
             {"Times-Bold", 16}], {0, -1.2}]
     },
     {AspectRatio -> Automatic,
      Background  -> RGBColor[1,1,0]
     }];
      
Show[myGraphics];

Step 8 - Use  Graphics[]  and the graphics primitives  Line[]  and  Text[]  to construct a graphics object called  goalPost  so you can superimpose it on  plot1.

Step 9 - Combine the graphics object  goalPost  with  plot1  using  Show[].

Step 10 - During a given MMA session, MMA saves all the input and output in memory, even if you delete material from your notebook.  The commands  ??In  and  ??Out  list all the input and output stored in memory.  Try typing  ??In.  What do you find?

Step 11 - Why might you want to delete the input and output information stored in memory?  To do so, you can use the following sequence of commands:

Unprotect[Out];
    Clear[Out]
    Protect[Out];
     
    Unprotect[In];
    Clear[In]
    Protect[In];

Find out about these commands and then use them to remove the input and output information stored in memory.  Verify that you were successful.

Comment 11

1.  These commands do not delete what's displayed in the notebook itself.
2.  Even if the memory is clear, the numbers labeling the input and output are not reset.

Save Your Notebook

Remove any output cells from this notebook and then use  Save As  to store your notebook under the name  myEx06.