11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

264 • Chapter 6: <strong>Programming</strong> with Maple Graphicsgraphs that have a large number of very small, almost invisible vectors.For example, a plot of the gradient field of F = cos(xy) exhibits thisbehavior.> vectorfieldplot( [y*cos(x*y), x*sin(x*y)],> x=0..Pi, y=0..Pi, grid=[15,20]);32.521.510.500.5 1 1.5 2 2.5 3The final version of vectorfieldplot differs in that all the arrowshave the same length—the color of each vector provides the informationabout the magnitudes of the arrows. Add a utility procedure that generatesa grid of colors from the function values.Example 7Utility Procedure> ‘convert/colorgrid‘ := proc( colorFunction )> local colorinfo, i, j, m, n;>> colorinfo := op( 3, convert(colorFunction,> ’gridpoints’, args[2..nargs] ) );> map( x -> map( y -> COLOR(HUE, y), x) , colorinfo );> end proc:This procedure uses the convert( ... , gridpoints) to generate alist of lists of function values that specify the colors (using hue coloring).> convert( sin(x*y), ’colorgrid’,> x=0..1, y=0..1, grid=[2,3] );[[COLOR(HUE , 0.), COLOR(HUE , 0.), COLOR(HUE , 0.)], [COLOR(HUE , 0.),COLOR(HUE , 0.479425538604203006),COLOR(HUE , 0.841470984807896505)]]Example 8Here is the final version of vectorfieldplot.

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

Saved successfully!

Ooh no, something went wrong!