Surface Graph in Cylindrical Coordinates

This shows an interactive graph in 3D in cylindrical coordinates.

Complete Code

Download file: CylindricalGraph3D.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'plotly3D.pl', 'PGcourse.pl');

Preamble

The dynamic graph is generated with plotly3D.pl.

$a = random(2, 5);

$graph1 = Graph3D();
$graph1->addSurface(
    [ 'u * cos(v)', 'u * sin(v)', "$a * cos(u^2 / 4)" ],
    [ 0,            6,            30 ],
    [ 0,            2 * pi,       30 ]
);

$graph2 = Graph3D();
$graph2->addSurface(
    [ 'r * cos(t)', 'r * sin(t)', 'r * sin(t)^2' ],
    [ 0,            6,            30 ],
    [ 0,            2 * pi,       30 ],
    variables => [ 'r', 't' ]
);

Setup

To add a plotly graph to a problem, first create a Graph3D object by calling the Graph3D method. Note that there are several options that can be passed to the Graph3D method that affect the display of the graph. This example uses the defaults for all of the options. Then add objects to the graph by calling the Graph3D object methods. This example demonstrates the usage of the addSurface method. Its syntax is

$graph->addSurface(
    [xFunction, yFunction, zFunction],
    [uMin, uMax, uCount],
    [vMin, vMax, vCount],
    options
);

where xFunction, yFunction, and zFunction are the parametric functions for the x, y, and z coordinates, respectively, uMin and uMax are the maximum and minimum values for the parameter u and uCount is the number of values in that range to use, vMin and vMax are the maximum and minimum values for the parameter v and vCount is the number of values in that range to use, and the options are additional options that can be set using the format option => value. Note that uCount and vCount are optional and both default to 20 if not given.

First, generate the graph for the function parameterized by x = u * cos(v), y = u * sin(v), and z = $a * cos(u^2 / 4) is generated. This graph uses the default variables u and v.

Second, generate the graph for the function parameterized by x = r * cos(t), y = r * sin(t), and z = r * sin(t)^2. Since the variables r and t are used and are not the default variables, those must be specified.

See plotly3D.pl for more details on the usage of the Graph3D object and its addSurface method.

BEGIN_PGML
[@ $graph1->Print @]*

[@ $graph2->Print @]*
END_PGML

Statement

If $graph is a Graph3D object, then insert its graph into the problem with [@ $graph->Print @]*.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.