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.

242 • Chapter 6: <strong>Programming</strong> with Maple Graphics> polygongrid := proc(gridlist, i, j)> gridlist[j][i], gridlist[j][i+1],> gridlist[j+1][i+1], gridlist[j+1][i];> end proc:Example 2 Use the makePolygongrid procedure to construct the appropriatepolygons.> makePolygongrid := proc(gridlist)> local m,n,i,j;> n := nops(gridlist);> m := nops(gridlist[1]);> POLYGONS( seq( seq( [ polygongrid(gridlist, i, j) ],> i=1..m-1), j=1..n-1) );> end proc:The following is a mesh of points in two-dimensional space.> L := [ seq( [ seq( [i-1, j-1], i=1..3 ) ], j=1..4 ) ];L := [[[0, 0], [1, 0], [2, 0]], [[0, 1], [1, 1], [2, 1]],[[0, 2], [1, 2], [2, 2]], [[0, 3], [1, 3], [2, 3]]]The makePolygongrid procedure creates the POLYGONS structure correspondingto L.> grid1 := makePolygongrid( L );grid1 := POLYGONS([[0, 0], [1, 0], [1, 1], [0, 1]],[[1, 0], [2, 0], [2, 1], [1, 1]], [[0, 1], [1, 1], [1, 2], [0, 2]],[[1, 1], [2, 1], [2, 2], [1, 2]], [[0, 2], [1, 2], [1, 3], [0, 3]],[[1, 2], [2, 2], [2, 3], [1, 3]])Put the polygons inside a PLOT structure to display them.> PLOT( grid1 );

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

Saved successfully!

Ooh no, something went wrong!