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.

6.4 <strong>Programming</strong> with Plot Data Structures • 239you should draw each wedge-shaped section of the gear as a triangularpolygon.> a := seq( [ [0, 0], outside(2*j, 1.1, 16) ], j=0..15 ):> b := seq( [ [0, 0], outside(2*j+1, 1, 16) ], j=0..15 ):> PLOT( POLYGONS(a,b), AXESSTYLE(NONE), SCALING(CONSTRAINED) );Adding STYLE(PATCHNOGRID) to the preceding structure and combiningit with the curve from the first picture creates a filled gear-likestructure. To embed this in three dimensions, at a thickness of t units,use the utility procedures> double := proc( L, t )> local u;> [ seq( [u[1], u[2], 0], u=L ) ],> [ seq( [u[1], u[2], t], u=L ) ];> end proc:which take a list of vertices and create two copies in three-dimensionalspace, one at height 0 and the second at height t, and> border := proc( L1, L2 )> local i, n;> n := nops(L1);> seq( [ L1[i], L2[i], L2[i+1], L1[i+1] ], i = 1..n-1 ),> [ L1[n], L2[n], L2[1], L1[1] ];> end proc:which input two lists of vertices and join the corresponding vertices fromeach list into vertices that make up quadrilaterals. You can create the topand bottom vertices of the gear embedded into three-dimensional spaceas follows.> faces :=> seq( double(p,1/2),> p=[ seq( [ outside(2*a+1, 1.1, 16), [0,0] ],> a=0..16 ),> seq( [ outside(2*a, 1,16), [0,0] ], a=0..16 )

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

Saved successfully!

Ooh no, something went wrong!