The Wiki page at

https://webwork.maa.org/wiki/ParametricPlots

shows how to draw a circle using parametric equations.

How do I add the tangent line?

The following code almost works,

but the tangent line is drawn vertical.

$gr = init_graph(-1.5,-1.5,1.5,1.5,

'axes'=>[0,0]);

#'grid' => [30,30],

#'pixels' => [400,400]);

$xfunc = sub {

my $t = shift();

if ($t<0) {

return $t+1;

} else {

return cos($t);

}

};

$yfunc = sub {

my $t = shift();

if ($t<0) {

return (3.0/4.0)*($t+1)-(25.0/4.0);

} else {

return sin($t);

}

};

$fn = new Fun( $xfunc, $yfunc, $gr );

$fn->domain(-1.0,6.2832);

to do a case analysis in code and in between

the cases a spurious line was drawn.) However,

it should be possibly to just add another function

to the graph object, and I couldn't figure out how

to do this.

In reply to joel robbin
Wednesday, 17 September 2008, 9:44 PM

### Re: parametric plots

by Michael Gage -
(it's the < sign that was interpreted as an HTML markup that caused the trouble in the post. )

To add two functions use this construction

To add two functions use this construction

$fn = new Fun( $xfunc, $yfunc, $gr ); $fn2 = new Fun( $xfunc2, $yfunc2, $gr ); which adds two Function objects to the graph $gr and also "stores" those objects in $fn and $fn2. Both functions will be plotted by the graph. More documentation can be found at: http://webwork.maa.org/doc/cvs/pg_CURRENT/ under Libraries: Fun and WWPlot Macros: PGgraphmacros.pl -- Mike