Parametric equations: graphing a parametric curve in space
Download file: SpaceCurveGraph.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'plotly3D.pl', 'PGcourse.pl');
Preamble
The macro plotly3D.pl
is used to produce the graph.
$graph = Graph3D( height => 300, width => 300, title => 'Spiral in 3D', ); $graph->addCurve([ 't*cos(t)', 't*sin(t)', 't' ], [ 0, 6 * pi, 150 ]);
Setup
A plotly3D
graph is created with the Graph3D
function. There are many options as decribed in the POD, but to get started include the height
and width
.
A parametric curve (space curve) is added to the graph with the addCurve
method, which takes an array ref of length 3. These are strings as javascript function in the variable t
. The second array ref is [tmin, tmax, samples]
.
BEGIN_PGML [@ $graph->Print @]* END_PGML ENDDOCUMENT();
Statement
This just prints the graph. No question is asked.