Difference between revisions of "3DGraphsParametricSurfaces"
(New page: <h2>Interactive Graphs of Parametric Surfaces in Three Dimensions</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black sol...) |
|||
Line 230: | Line 230: | ||
$plot1 . |
$plot1 . |
||
"," . |
"," . |
||
− | "{RGBColor[0,1,0],Thickness[0.012],Line[{{-1,0,0},{-0.5,0,0}}], |
+ | "{RGBColor[0,1,0],Thickness[0.012],Line[{{-1,0,0},{-0.5,0,0}}], |
+ | Line[{{-0.5,0,0},{-0.6,0.1,0}}],Line[{{-0.5,0,0},{-0.6,-0.1,0}}]}" . |
||
"," . |
"," . |
||
− | "{RGBColor[1,0,0],Thickness[0.012],Line[{{-1,0,0},{-1.5,0,0}}], |
+ | "{RGBColor[1,0,0],Thickness[0.012],Line[{{-1,0,0},{-1.5,0,0}}], |
+ | Line[{{-1.5,0,0},{-1.4,0.1,0}}],Line[{{-1.5,0,0},{-1.4,-0.1,0}}]}" . |
||
"," . |
"," . |
||
− | "{RGBColor[0,0,0],Thickness[0.012],Line[{{0,1,0},{0,0.646,0.353}}], |
+ | "{RGBColor[0,0,0],Thickness[0.012],Line[{{0,1,0},{0,0.646,0.353}}], |
+ | Line[{{0,0.646,0.353},{0,0.646,0.253}}],Line[{{0,0.646,0.353},{0,0.746,0.353}}]}" . |
||
"," . |
"," . |
||
− | "{RGBColor[0,0,0],Thickness[0.012],Line[{{1,0,0},{1,0,0.5}}], |
+ | "{RGBColor[0,0,0],Thickness[0.012],Line[{{1,0,0},{1,0,0.5}}], |
+ | Line[{{1,0,0.5},{1,0.1,0.4}}],Line[{{1,0,0.5},{1,-0.1,0.4}}]}" . |
||
"," . |
"," . |
||
− | "{RGBColor[0,0,0],Thickness[0.012],Line[{{0,-1,0},{0,-1.353,0.353}}], |
+ | "{RGBColor[0,0,0],Thickness[0.012],Line[{{0,-1,0},{0,-1.353,0.353}}], |
+ | Line[{{0,-1.353,0.353},{0,-1.353,0.253}}],Line[{{0,-1.353,0.353},{0,-1.246,0.353}}]}" . |
||
"}" . |
"}" . |
||
",Axes->False,AxesLabel->{X,Y,Z},Boxed->False" . |
",Axes->False,AxesLabel->{X,Y,Z},Boxed->False" . |
Revision as of 01:05, 27 April 2010
Interactive Graphs of Parametric Surfaces in Three Dimensions
This PG code shows how to generate interactive graphs of parametric surfaces from MathObjects formulas. It uses the Java applet LiveGraphics3D to display the interactive graph.
- Example 1: A sphere.
- Example 2: A Moebius band with some orientation vectors.
Example 1: A sphere.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserVectorUtils.pl", "PGcourse.pl", "LiveGraphicsParametricSurface3D.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macros file |
Context("Numeric"); Context()->variables->are(x=>"Real",y=>"Real",z=>"Real",u=>"Real",v=>"Real"); $plot = ParametricSurface3D( Fx => Formula("3*cos(u)*sin(v)"), Fy => Formula("3*sin(u)*sin(v)"), Fz => Formula("3*cos(v)"), uvar => 'u', # theta vvar => 'v', # phi umin => 0, umax => 2*pi, vmin => 0, vmax => pi, usamples => 15, vsamples => 15, axesframed => 1, xaxislabel => "X", yaxislabel => "Y", zaxislabel => "Z", mesh => 0, outputtype => 4, ); |
Setup:
We generate a string of plot data using
Setting |
Context()->texStrings; BEGIN_TEXT \{ Live3Ddata( $plot, image => "sphere.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
After you construct the graph you like, don't forget to take a screen shot of it and make an image file such as |
$showPartialCorrectAnswers = 1; ENDDOCUMENT(); |
Answer Evaluation: Nothing happening here. |
Example 2: A Moebius band with some orientation vectors.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserVectorUtils.pl", "PGcourse.pl", "LiveGraphicsParametricSurface3D.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macros file |
Context("Numeric"); Context()->variables->are(x=>"Real",y=>"Real",z=>"Real",u=>"Real",v=>"Real"); $plot1 = ParametricSurface3D( Fx => Formula("cos(v)+u*cos(v/2)*cos(v)"), Fy => Formula("sin(v)+u*cos(v/2)*sin(v)"), Fz => Formula("u*sin(v/2)"), uvar => 'u', vvar => 'v', umin => -0.4, umax => 0.4, vmin => 0, vmax => 2*pi, usamples => 1, vsamples => 90, axesframed => 0, xaxislabel => "X", yaxislabel => "Y", zaxislabel => "Z", mesh => 0, outputtype => 1, ); $plot = $beginplot . "{" . $plot1 . "," . "{RGBColor[0,1,0],Thickness[0.012],Line[{{-1,0,0},{-0.5,0,0}}], Line[{{-0.5,0,0},{-0.6,0.1,0}}],Line[{{-0.5,0,0},{-0.6,-0.1,0}}]}" . "," . "{RGBColor[1,0,0],Thickness[0.012],Line[{{-1,0,0},{-1.5,0,0}}], Line[{{-1.5,0,0},{-1.4,0.1,0}}],Line[{{-1.5,0,0},{-1.4,-0.1,0}}]}" . "," . "{RGBColor[0,0,0],Thickness[0.012],Line[{{0,1,0},{0,0.646,0.353}}], Line[{{0,0.646,0.353},{0,0.646,0.253}}],Line[{{0,0.646,0.353},{0,0.746,0.353}}]}" . "," . "{RGBColor[0,0,0],Thickness[0.012],Line[{{1,0,0},{1,0,0.5}}], Line[{{1,0,0.5},{1,0.1,0.4}}],Line[{{1,0,0.5},{1,-0.1,0.4}}]}" . "," . "{RGBColor[0,0,0],Thickness[0.012],Line[{{0,-1,0},{0,-1.353,0.353}}], Line[{{0,-1.353,0.353},{0,-1.353,0.253}}],Line[{{0,-1.353,0.353},{0,-1.246,0.353}}]}" . "}" . ",Axes->False,AxesLabel->{X,Y,Z},Boxed->False" . "," . "ViewPoint->{1.618,-2.236,1.956},ViewVertical->{-0.276,0.561,2.6213}" . $endplot; |
Setup:
We generate a string of plot data using
Setting |
Context()->texStrings; BEGIN_TEXT \{ Live3Ddata( $plot, image => "moebius-band.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
After you construct the graph you like, don't forget to take a screen shot of it and make an image file such as |
$showPartialCorrectAnswers = 1; ENDDOCUMENT(); |
Answer Evaluation: Nothing happening here. |