Difference between revisions of "SpacecurveGraph1"

From WeBWorK_wiki
Jump to navigation Jump to search
m
Line 5: Line 5:
 
This PG code shows how to make an interactive graph of a parametric curve in 3D space that is displayed using the LiveGraphics3D Java applet.
 
This PG code shows how to make an interactive graph of a parametric curve in 3D space that is displayed using the LiveGraphics3D Java applet.
 
</p>
 
</p>
* Download file: [[File:SpacecurveGraph1.txt]] (change the file extension from txt to pg when you save it)
 
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Parametric/Spacecurve1.pg FortLewis/Authoring/Templates/Parametric/SpacecurveGraph1/SpacecurveGraph1.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Parametric/SpacecurveGraph1/SpacecurveGraph1.pg</code>
 
   
 
<br clear="all" />
 
<br clear="all" />
Line 148: Line 147:
 
Context()->texStrings;
 
Context()->texStrings;
 
BEGIN_SOLUTION
 
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
 
 
Solution explanation goes here.
 
Solution explanation goes here.
 
END_SOLUTION
 
END_SOLUTION

Revision as of 16:13, 16 June 2013

Interactive Graph of a Parametric Curve in 3D Space

Click to enlarge

This PG code shows how to make an interactive graph of a parametric curve in 3D space that is displayed using the LiveGraphics3D Java applet.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"LiveGraphicsParametricCurve3D.pl",
);

TEXT(beginproblem());

Initialization: We need to include the macro file LiveGraphicsParametricCurve3D.pl.

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

$plot = ParametricCurve3D(
Fx => Formula("t*cos(t)"),
Fy => Formula("t*sin(t)"),
Fz => Formula("t"),
tvar => "t",
tmin =>  0,
tmax =>  10,
tsamples => 50,
axesframed => 1,
xaxislabel => "X",
yaxislabel => "Y",
zaxislabel => "Z",
outputtype => 4,
);

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

Setting outputtype to something other than 4 will require you to read the source code of LiveGraphicsParametricCurve3D.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 => "spiral.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 spiral.png that will be used in the pdf hardcopy.

$showPartialCorrectAnswers = 1;

Answer Evaluation:

Context()->texStrings;
BEGIN_SOLUTION
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area