11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

246 • Chapter 6: <strong>Programming</strong> with Maple GraphicsA Dropshadow ProcedureYou can use the existing procedures to create other types of plots thatare not part of the Maple graphics library. For example, the followingprocedure computes the three-dimensional plot of a surface, z = f(x, y),that has a dropshadow projection onto a plane located below the surface.Example The procedure uses the commands contourplot, contourplot3d,and display from the plots package, and transform from the plottoolspackage.> dropshadowplot := proc(F::algebraic, r1::name=range,> r2::name=range, r3::name=range)> local minz, p2, p3, coption, opts, f, g, x, y;>> # set the number of contours (default 8)> opts := [args[5..nargs]];> if not hasoption( opts, ’contours’, coption, ’opts’ )> then coption := 8;> end if;>> # determine the base of the plot axes> # from the third argument> minz := lhs(‘if‘(r3::range, r3, rhs(r3)));> minz := evalf(minz);>>> # create 2d and 3d contour plots for F.> p3 := plots[contourplot3d]( F, r1, r2,> ’contours’=coption, op(opts) );> p2 := plots[contourplot]( F, r1, r2,> ’contours’=coption, op(opts) );>> # embed contour plot into R^3 via plottools[transform]> g := unapply( [x,y,minz], x, y );> f := plottools[transform]( g );> plots[display]([ f(p2), p3 ]);> end proc:The filled=true option to contourplot and contourplot3d causesthese two commands to fill the regions between the level curves with acolor that indicates the level.> expr := -5 * x / (x^2+y^2+1);expr := −5xx 2 + y 2 + 1> dropshadowplot( expr, x=-3..3, y=-3..3, z=-4..3,> filled=true, contours=3, axes=frame );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!