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 • 237> vertices := seq( evalf( [ x[1] + r*cos(2*Pi*i/n),> x[2] + r*sin(2*Pi*i/n) ] ),> i = 0..n );> POLYGONS( [vertices], op(opts) );> end proc:To display two disks connected by a line:> with(plots):Warning, the name changecoords has been redefined> display( disk([-1, 0], 1/2, color=plum),> line([-1, 1/2], [1, 1/2]),> disk([1, 0], 1/2, thickness=3),> scaling=constrained );0.40.2–1.5 –1 –0.5–0.20.5 1 1.5–0.4The options to the individual objects apply only to those objects.Plotting GearsThe following example shows how you can manipulate plotting data structuresto embed two-dimensional plots into a three-dimensional setting.Example 1 The following procedure creates part of the boundary of atwo-dimensional graph of a gear-like structure.> outside := proc(a, r, n)> local p1, p2;> p1 := evalf( [ cos(a*Pi/n), sin(a*Pi/n) ] );> p2 := evalf( [ cos((a+1)*Pi/n), sin((a+1)*Pi/n) ] );> if r = 1 then p1, p2;> else p1, r*p1, r*p2, p2;> end if> end proc:For example

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

Saved successfully!

Ooh no, something went wrong!