3DGraphsInCylindrical

From WeBWorK_wiki
Revision as of 01:48, 27 April 2010 by Pearson (talk | contribs) (New page: <h2>Interactive Graphs of Functions in Cylindrical Coordinates in Three Dimensions</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Interactive Graphs of Functions in Cylindrical Coordinates in Three Dimensions


This PG code shows how to generate interactive graphs of functions from a MathObjects formula. It uses the Java applet LiveGraphics3D to display the interactive graph.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserVectorUtils.pl",
"PGcourse.pl",
"LiveGraphicsCylindricalPlot3D.pl",
);

TEXT(beginproblem());

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

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

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

$plot = CylindricalPlot3D(
function => Formula("$a*cos((r^2)/4)"),
rvar => "r",
tvar => "t",
rmin =>  0,
rmax =>  6,
tmin =>  0,
tmax =>  2*pi,
rsamples => 20,
tsamples => 15,
axesframed => 1,
xaxislabel => "X",
yaxislabel => "Y",
zaxislabel => "Z",
outputtype => 4,
);

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

Setting outputtype to something other than 4 will require you to read the source code of LiveGraphicsCylindricalPlot3D.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
\{ 
Live3Ddata(
$plot,
image => "wavy-surface.png", 
size => [400,400],
tex_size => 600,
tex_center => 1,
scale => 1.1,
);
\}
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 an image file such as wavy-surface.png that will be used in the pdf hardcopy.

$showPartialCorrectAnswers = 1;

ENDDOCUMENT();

Answer Evaluation: Nothing happening here.

Problem Techniques Index