Question: Difference between with(geometry) and with(plots? rectangle - color?

I am perplexed about the geometry and plots packages.  When starting a programme involving geometric shapes, how does one decide which to use?  ..Or can the two packages be used in the same programme?  To iiiustrate my question there is a text program below which draws a diagram of a large square, with a circle inscribed tangentially to the square.  There is then a further smaller concentric circle, with a square drawn inside; the vertices touching this circle.  (It isdesigned as a problem suitable for young high-school teenagers.)

   I wanted to fill in various regions of this diagram in colors red and green.  I believe the with(geometry) package does this easily.  However, as I'm more used to the with(plots) package I stuck to this.  To get the coloured regions I drew a sequence of colored lines.  I also drew a colored square (See    SmallSq:=[op(SmallSq),sq_small||ii]:   ) by drawing a seq of concentric squares.  At the end of my program there are two almost identical plots[display] commands.   The difference is that the first does not incude the SmallSq.  I was expecting the two displays to be identical, since I'd specified the color white.  The first display has a dark colored square.  Why?? .  

   .   The program is very klutsy!  I'm embarrassed to publish it:-(  The SmallSq is adequate for my purposes, but has several white spaces - almost dots - on the dark version.  The thickness and style of the lines was the widest possible  - perhaps I should have set the larger rarius R, to a bigger value?

   And I have a feeling this diagram could have been constructed ib the geometry package in far fewer lines of code!

As always, any comments, suggestions would be most appreciated.

  David

 

 

> restart:
> # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Maple 7
> # Area puzzle involving squares & circles
> #To Do:  fill areas with color
> #  Use segment command and seq to make a set of colored lines
> #NB  Numbering for lines L1 is 1,2,3,4 for N,E,S,West
> #    Numbering for lines L2 is 1,2,4,3 for N,E,S,West
> # # # # # # # # # # # # # # # # # # # # # # # # # # # #
> with(plots):
> with(plottools):
> print(`The diagram shows two squares and two circles.`);
> print(`The red and green regions are equal in area.`);
> print(`To find the ratio of the radius of the large circle to the
> smaller.`);

> #Doesn't seem to like a combination of geometry & with plots
> #with(geometry);
> r:=R*sqrt((4-Pi)/(Pi-2));  #for the pretty printout only!
> R:=49:
> r:=R*sqrt((4-Pi)/(Pi-2)):  #give r a numerical value
> c_big := circle([0,0], R, color=red):
> c_small := circle([0,0], r, color=green):
> sq_big := rectangle([-R,R], [R,-R], color=white):
> #sq_small := rectangle([-r/sqrt(2),r/sqrt(2)], [r/sqrt(2),-r/sqrt(2)],
> color=white):
> #y:=R/2:

> SmallSq:=[]:
> for ii from 1 to round(r) do
> sq_small||ii := rectangle([-ii/sqrt(2),ii/sqrt(2)],
> [ii/sqrt(2),-ii/sqrt(2)], color=white,linestyle=1 , thickness=3):
> SmallSq:=[op(SmallSq),sq_small||ii]:
> end do:

> Llines1:=[]:Llines2:=[]:Llines3:=[]:Llines4:=[]:
> for yy from 1 by 1 to R do
> l1||yy := line([-R,yy], [-sqrt(R^2-yy^2),yy], color=red, linestyle=1 ,
> thickness=3):
> l2||yy := line([sqrt(R^2-yy^2),yy], [R,yy], color=red, linestyle=1 ,
> thickness=3):
> l3||yy := line([sqrt(R^2-yy^2),-yy], [R,-yy], color=red, linestyle=1 ,
> thickness=3):
> l4||yy := line([-sqrt(R^2-yy^2),-yy], [-R,-yy], color=red, linestyle=1
> , thickness=3):
> #List of lines is Llines
> Llines1:=[op(Llines1),l1||yy]:
> Llines2:=[op(Llines2),l2||yy]:
> Llines3:=[op(Llines3),l3||yy]:
> Llines4:=[op(Llines4),l4||yy]:
> end do:
> first:=round(r*(sqrt(2))/2)+1:
> last:=round(r):
> L2lines1:=[]:L2lines2:=[]:L2lines2D:=[]:L2lines3:=[]:L2lines3Up:=[]:L2
> lines4:=[]:
> for yy from first by 1 to last do
> l2_1||yy := line([-sqrt(r^2-yy^2),yy], [sqrt(r^2-yy^2),yy],
> color=green, linestyle=1 , thickness=3):
> #l2_2||yy := line([yy,r/sqrt(2)],[yy,sqrt(r^2-yy^2)],  color=green,
> linestyle=1 , thickness=3):
> l2_2||yy := line([yy,sqrt(r^2-yy^2)],[yy,0],  color=green, linestyle=1
> , thickness=3):
> l2_2D||yy := line([yy,-sqrt(r^2-yy^2)],[yy,0],  color=green,
> linestyle=1 , thickness=3):

> l2_3||yy := line([-yy,-sqrt(r^2-yy^2)],[-yy,0],  color=green,
> linestyle=1 , thickness=3):
> l2_3Up||yy := line([-yy,sqrt(r^2-yy^2)],[-yy,0],  color=green,
> linestyle=1 , thickness=3):

> l2_4||yy := line([-sqrt(r^2-yy^2),-yy], [sqrt(r^2-yy^2),-yy],
> color=green, linestyle=1 , thickness=3):
> #List of lines is Llines
> L2lines1:=[op(L2lines1),l2_1||yy]:
> L2lines2:=[op(L2lines2),l2_2||yy]:
> L2lines2D:=[op(L2lines2D),l2_2D||yy]:
> L2lines3:=[op(L2lines3),l2_3||yy]:
> L2lines3Up:=[op(L2lines3Up),l2_3Up||yy]:
> L2lines4:=[op(L2lines4),l2_4||yy]:
> end do:


> plots[display](c_big,c_small,Llines1,Llines2,Llines3,L2lines1,L2lines2
> ,L2lines2D,Llines4, L2lines3,L2lines3Up,L2lines4,
> scaling=constrained);
> plots[display](c_big,c_small,Llines1,Llines2,Llines3,Llines4,L2lines1,
> L2lines2,L2lines2D,L2lines3,L2lines3Up,
> L2lines4,SmallSq,scaling=constrained);


Warning, the name changecoords has been redefined

Warning, the name arrow has been redefined


            The diagram shows two squares and two circles.


             The red and green regions are equal in area.


  To find the ratio of the radius of the large circle to the small\
        er.


                                     4 - Pi
                         r := R sqrt(------)
                                     Pi - 2
 

Please Wait...