From: Mike G. v. a. <we...@ma...> - 2007-10-27 14:21:53
|
Log Message: ----------- Changed plot_functions so that it uses the Formula MathObject to parse the the function in $f1 = qq! x^2 - 3*x + 45 for x in [0, 45) using color:red and weight:2! instead of using the built in perl parser. This allows things such as $formula=Formula("|x|"); $f1 = qq! $formula for x in [0, 45) using color:red and weight:2! to be evaluated. There should be no apparent change to old problems since the Formula MathObject parser handles a superset of the builtin perl parser syntax. This is not yet the most efficient method to have GraphObjects and Formula's interact since the same string is being recompiled several times, but it is a useful hack which preserves backward compatibility. Modified Files: -------------- pg/macros: PGgraphmacros.pl Revision Data ------------- Index: PGgraphmacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGgraphmacros.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -Lmacros/PGgraphmacros.pl -Lmacros/PGgraphmacros.pl -u -r1.6 -r1.7 --- macros/PGgraphmacros.pl +++ macros/PGgraphmacros.pl @@ -16,7 +16,7 @@ This collection of macros provides easy access to the facilities provided by the graph module WWPlot and the modules for objects which can be drawn on a graph: functions (Fun.pm) -labels (Label.pm) and images. The only image implemented currently are open and closed circles +labels (Label.pm) and images. The only images implemented currently are open and closed circles (Circle) which can be used to mark graphs of functions defined on open and closed intervals. These macros provide an easy ability to graph simple functions. More complicated projects @@ -315,8 +315,8 @@ } else { $weight =2; } - - my $subRef = string_to_sub($rule,$var); + my $subRef = Formula($rule)->perlFunction(undef,[$var]); + # my $subRef = string_to_sub($rule,$var); my $funRef = new Fun($subRef,$graph); $funRef->color($color); $funRef->weight($weight); @@ -343,6 +343,9 @@ @functions; # return function references unless there is an error. } + + + =head2 insertGraph $filePath = insertGraph(graphObject); |