Parametric equations: graphing a parametric curve in space
Download file: SurfaceGraph.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 => 'Sphere',
);
$graph->addSurface(
[ '3 * sin(v) * cos(u)', '3 * sin(v) * sin(u)', '3 * cos(v)' ],
[ 0, 2 * pi, 30 ],
[ 0, pi, 30 ]
);
Setup
A plotly3D graph is created with the
Graph3D function. There are many options as decribed in plotly3D
macro documentation. In this example, only the height,
width, and title are provided.
A parametric surface is added to the graph with the
addSurface method, which takes 3 array references with each
array of length 3. These parameters are described below.
u and
v whose values are the x, y, and
z coordinates, respectively, of a point on the surface. For
example, 3 * sin(v) * cos(u) becomes
(u, v) => 3 * sin(v) * cos(u).u, and the number of samples to use for
u.v, and the number of samples to use for
v.BEGIN_PGML [@ $graph->Print @]* END_PGML ENDDOCUMENT();
Statement
Insert the graph into the problem.