Eight turtles forming eight graphics handles and a rectangle instead of a CIRCLE

This is a quiz two followup (April 2011 quiz)


Forward 8 steps for the EVEN turtles, but FORWARD squareRootOf(128) steps or FORWARD 11.31371 steps for the ODD turtles. 8 ^ 2 + 8 ^ 2 = 64 + 64 = 128. The length of each of the two equal sides of the right triangle is 128.

cro 8 creates 8 turtles, staggered to face 0, 45, 90, 135, 180, 225, 270, 315, 360 degrees. The EVEN turtles face 0, 90, 180 ad 270 degrees.

CRO 32 turtles and have them step fd 8 or 10 steps. The 32 turtles form a perfect CIRCLE, NOT a RECTANGLE.

Quantitative Thinking - Right Triangles: Pythagorean Theorem


In any right triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The ODD turtles draw the HYPOTENUSE. The EVEN turtles draw the LEGS.

powered by NetLogo

view/download model file: EightGraphicsHandlesEvenOdd.nlogo

WHAT IS IT? Even turtles walk length of a LEG, ODD do the length of hypotenuse.

ifelse remainder who 2 = 0 
[
     slowWalk 8       ;; Even turtles move 8 units
]
[
     slowWalk sqrt (8 ^ 2 + 8 ^ 2)  
]

HOW IT WORKS to do the slow walking forward moves

TO moveEm [ n ]
  ifelse remainder who 2 = 0 
      [
         slowWalk n   wait 0.1
      ]
      [       
         slowWalk sqrt (n ^ 2 + n ^ 2)   wait 0.1
      ]           
end

HOW to show the squares (PATCHES) - checkerBoard procedure

To checkerBoard
    ask patches 
    [ 
       ifelse remainder (pxcor + pycor) 2 = 0 
          [ 
              set pcolor white 
          ]
          [ 
              set pcolor yellow 
          ]
    ]
end


THINGS TO NOTICE - slowWalk procedure

TO slowWalk [ howFar ]

   repeat 20
   [
     fd (howFar / 20) 
     wait 0.1
   ]
     
end


THINGS TO TRY

TO outline8GraphicsHandles     ;; Try out the outline8GraphicsHandles    

   ca 
   checkerboard
   
   cro 8
   
   ask-concurrent turtles       ;; If you want the ODD turtles share a row with one even
   [                            ;; turtle and share a column with another even turtle
      pd                        ;; they need to WALK FORWARD the length of the hypotenuse
      set pen-size 2            ;; of the sides of the right triangle (see Pythagorous)
      set color black
      
      ifelse remainder who 2 = 0 
      [
         slowWalk 8              ;; Even turtles move 8 units
      ]
      [
         slowWalk sqrt (8 ^ 2 + 8 ^ 2)      ;; Odd turtles move square root of 128 units
      ]                                     ;; Odd turtle move about 11.3 units
            
                                      ;; 11.31371 ^ 2 =  128.0000339641
   ]                                  ;; 8 squared plus 3 squared = 64 + 64 = 128
END                                   ;; square root (128) = 11.31371


EXTENDING THE MODEL

TO form4corners4sides       ;; Try form4corners4sides (instead of CIRCLE of turtles)
    ca                      ;; to see pattern with PU then PD then PU.
    checkerboard            ;; The 8 turtles outline a RECTANGLE, not a CIRCLE...
    
    cro 8
    
    ask-concurrent turtles
    [
      set pen-size 2
      set color blue
      
      moveEm 2
      
      pd
      
      moveEm 3
      
      pu
      
      moveEm 3
    ]
END

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.


RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.


CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.


PROCEDURES

TO outline8GraphicsHandles        ;; Try out the outline8GraphicsHandles    

   ca 
   checkerboard
   
   cro 8
   
   ask-concurrent turtles                    ;; If you want the ODD turtles share a row with one even
   [                              ;; turtle and share a column with another even turtle
      pd                          ;; they need to WALK FORWARD the length of the hypotenuse
      set pen-size 2              ;; of the sides of the right triangle (see Pythagorous)
      set color black
      
      ifelse remainder who 2 = 0 
      [
         slowWalk 8                         ;; Even turtles move 8 units
      ]
      [
         slowWalk sqrt (8 ^ 2 + 8 ^ 2)      ;; Odd turtles move square root of 128 units
      ]                                     ;; Odd turtle move about 11.3 units
            
                                      ;; 11.31371 ^ 2 =  128.0000339641
   ]                                  ;; 8 squared plus 3 squared = 64 + 64 = 128
END                                   ;; square root (128) = 11.31371

To checkerBoard
    ask patches [ 
      ifelse remainder (pxcor + pycor) 2 = 0 
                       [ set pcolor white ]
                       [ set pcolor yellow ]
    ]
end


TO moveEm [ n ]
  ifelse remainder who 2 = 0 
      [
         slowWalk n wait 0.1
      ]
      [       
         slowWalk sqrt (n ^ 2 + n ^ 2) wait 0.1
      ]           
end

TO form4corners4sides                 ;; Try form4corners4sides (instead of CIRCLE of turtles)
    ca                                ;; to see pattern with PU then PD then PU.
    checkerboard                      ;; The 8 turtles outline a RECTANGLE, not a CIRCLE...
    
    cro 8
    
    ask-concurrent turtles
    [
      set pen-size 2
      set color blue
      
      moveEm 2
      
      pd
      
      moveEm 3
      
      pu
      
      moveEm 3
    ]
END

TO slowWalk [ howFar ]

   repeat 20
   [
     fd (howFar / 20) 
     wait 0.1
   ]
     
end