Difference between revisions of "3DGraphsVectorFields"

From WeBWorK_wiki
Jump to navigation Jump to search
m (4 revisions: import all default namespace pages from old wiki)
(added historical tag and gave updated problem link)
 
Line 1: Line 1:
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/VectorCalc/VectorFieldGraph3D/VectorFieldGraph3D1.html a newer version of this problem]</p>
 
<h2>Vector Fields in Three Dimensions</h2>
 
<h2>Vector Fields in Three Dimensions</h2>
   

Latest revision as of 11:07, 29 June 2023

This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem

Vector Fields in Three Dimensions


This PG code shows how to display vector fields in three dimensions that are defined by formulas.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();

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

TEXT(beginproblem());

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

Context("Numeric");

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

$plot = VectorField3D(
Fx => Formula("y"),
Fy => Formula("-x"),
Fz => Formula("z"),
xvar => 'x',
yvar => 'y',
zvar => 'z',
xmin => -1,
xmax =>  1,
ymin => -1,
ymax =>  1,
zmin => -1,
zmax =>  1,
xsamples => 4,
ysamples => 4,
zsamples => 4,
axesframed => 1,
xaxislabel => "X",
yaxislabel => "Y",
zaxislabel => "Z",
vectorcolor => "RGBColor[1.0,0.0,0.0]",
vectorscale => 0.2,
vectorthickness => 0.01,
outputtype => 4,
);

Setup: The VectorField3D() routine returns a string of plot data consisting of a list of line segments (the vectors) along with other plot options. The arguments RGBColor[a,b,c] are numbers a, b, and c between 0 and 1 inclusive. You can uniformly scale all of the vectors in the vector field by the same amount using vectorscale. The outputtype feature controls how much of the string of plot data is generated, and setting it equal to 4 generates all of the plot information necessary to be displayed.

Setting outputtype to something other than 4 will require you to read the source code of LiveGraphicsVectorField3D.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
$BCENTER
\{ 
Live3Ddata(
$plot,
image => "cool-vector-field.png", 
size => [400,400],
tex_size => 600,
tex_center => 1,
scale => 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 automatically loaded by LiveGraphicsVectorField3D.pl.

After you construct the vector field you like, don't forget to take a screen shot of it and make an image file such as cool-vector-field.png that will be used in the pdf hardcopy.

$showPartialCorrectAnswers = 1;

ENDDOCUMENT(); 

Answer Evaluation: We didn't ask any questions, so this is uninteresting.

Problem Techniques Index