Graph3DRectangular1

From WeBWorK_wiki
Revision as of 17:08, 19 December 2010 by Pearson (talk | contribs) (Created page with '<h2>Interactive Graph of a Function in Rectangular Coordinates in 3D</h2> 300px|thumb|right|Click to enlarge <p style="background-color:#f9f9f9;…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Interactive Graph of a Function in Rectangular Coordinates in 3D

Click to enlarge

This PG code shows how to use the LiveGraphics3D Java applet to display an interactive graph of a function in rectangular coordinates.

  • Download file: File:Graph3DRectangular1.txt (change the file extension from txt to pg when you save it)
  • File location in NPL: FortLewis/Authoring/Templates/DiffCalcMV/Graph3DRectangular1/Graph3DRectangular1.pg


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:


DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPopUp.pl",
"LiveGraphicsRectangularPlot3D.pl",
);

TEXT(beginproblem());

Initialization: We need to include the macros file LiveGraphicsRectangularPlot3D.pl.

Context("Numeric");

Context()->variables->are(x=>"Real",y=>"Real",r=>"Real",s=>"Real",t=>"Real");

$a = - random(-1,1,2);

$plot = RectangularPlot3DRectangularDomain(
function => Formula("t^2+$a*s^2"),
xvar => "s",
yvar => "t",
xmin => -2,
xmax =>  2,
ymin => -2,
ymax =>  2,
xsamples => 10,
ysamples => 10,
axesframed => 1,
xaxislabel => "S",
yaxislabel => "T",
zaxislabel => "Z",
outputtype => 4,
);

if ( $a == -1) {
  $im = "hyperbolic-paraboloid.png";
  $pop = PopUp(
     ["Choose","Paraboloid","Hyperbolic paraboloid"],
     "Hyperbolic paraboloid");
} else {
  $im = "paraboloid.png";
  $pop = PopUp(
     ["Choose","Paraboloid","Hyperbolic paraboloid"],
     "Paraboloid");
}

Setup: We generate a string of plot data using RectangularPlot3DRectangularDomain().

Setting outputtype to something other than 4 will require you to read the source code of LiveGraphicsRectangularPlot3D.pl and familiarize yourself with the details of the LiveGraphics3D java applet. For more information on how to work with the string of plot data, see Martin Kraus's LiveGraphics3D homepage, and the excellent article by Jonathan Rogness and Martin Kraus Constructing Mathlets Quickly Using LiveGraphics3D.

Context()->texStrings;
BEGIN_TEXT
The graph below is called a 
\{ $pop->menu() \}
$PAR
$BCENTER
\{ 
Live3Ddata(
$plot,
image => "hyperbolic-paraboloid.png", 
size => [400,400],
tex_size => 600,
tex_center => 1,
scale => 1.1,
);
\}
$ECENTER
END_TEXT
Context()->normalStrings;

Main Text: To display the string of plot data $plot, we use the Live3Ddata() routine provided by the macro LiveGraphics3D.pl, which is loaded automatically.

After you construct the graph you like, don't forget to take a screen shot of it and make image files such as hyperbolic-paraboloid.png and paraboloid.png that will be used in the pdf hardcopy.

$showPartialCorrectAnswers = 1;

ANS( $pop->cmp() );

Answer Evaluation:

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area