Home
Project Folders
Teacher Resources
Student Resources
En ESPAÑOL
How Do I?
Vocabulary
MWForum
Site Map
Search
Our Team

polygons 1 2 3 4 5 6 7 8 9
Polygons 5
Download
5 KB


Goal:   Create a polygon starting from the center point.


Screenshot


Vocabulary:   + (addition sign), setpos, pos, if, touching?, seth (setheading)

Code
Project Map

to polygon
t1, pu
t2, pu
setc whatcolor
setpensize howthick
repeat 1 + #sides [
t1, fd howbig
t2,
setpos t1's "pos
if touching? "t2 "t1 [pd]
t1, bk howbig rt 360 / #sides
]
end

to reset
everyone [home]
cg
end



Notes

In this project, the howbig slider sets the distance from the center point to each vertex (corner) of the polygon; it does not set the length of each side as in Polygons 2, 3, and 4.   As in Project 4, turtle t2 follows turtle t1, but this time t2 draws the polygon.

  1. Set both turtles to a small shape such as a dot.
    Turtle t1 keeps its pen up throughout the project.  

    Revise the polygons procedure:

  2. If touching? "t2 "t1 [pd] means: "t2's pen is up until it moves to touch t1 for the first time; then it puts its pen down to draw."

  3. setpos t1's "pos means: "t2 will set its position to t1's position - the same x and y coordinates."   (Note: It is also possible to move t2 to t1's position using towards and distance as in Polygons 4.   This project demonstrates an alternate method.)

  4. The repeat command is repeated 1 + #sides to allow t2 to complete the polygon.   The first repetition brings t1 and t2 to the uppermost vertex of the polygon.   Now the turtles need to move to each vertex of the polygon and return once again to the uppermost vertex.   When several commands are included inside one set of brackets, the brackets themselves can placed on a separate line.




What If?
What design does t1 draw if you set its pen down (pd) at the beginning of the polygon procedure?


Challenge
Can you revise the polygon procedure to use towards and distance for moving t2 to t1's position? (See Polygons 4.)


On Your Own - Project Ideas
Create a design with several nested polygons with no overlapping edges, using the same center point.





© copyright 2001 - 2016  OpenWorld Learning.   All rights reserved.