Goal: Find the length of the sides of a polygon drawn around a center point.
Vocabulary: set, int
to polygon
t1, pu
t2, pu
setc whatcolor
setpensize howthick
repeat 1 + #sides [
t1, fd howbig
t2,
setlength_of_side int distance "t1
wait 10
setpos t1's "pos
if touching? "t2 "t1 [pd]
t1, bk howbig rt 360 / #sides
]
end
to reset
everyone [home]
cg
end
Notes  Create a text box and name it length_of_side. (It is better if the text box name doesn't contain spaces.) If you wish, use the text menu to change the font and size of the text.
 In the revised polygon procedure, Setlength_of_side means: "Set the contents of the text box named length_of_side to the following input."
 Int distance "t1 means: "Measure the distance from the current turtle to t1 and report only the integer portion of the number (don't include any decimal portion)."
Now as t2 prepares to move to each new position of t1, it measures and reports the distance in the text box. You can compare the number(s) reported in the text box to the number on the howbig slider.
What If?
What happens if you remove the word int ?
Challenge
Compare the number in the text box to the number on the howbig slider (the measurement from the center point to each vertex). Try different polygons. For which polygon(s) is the length of each side less than howbig? For which polygon(s) is the length of each side greater than howbig? For which polygon(s) is the length of each side equal to howbig?
What is the largest possible side length for a triangle? square? pentagon?
On Your Own  Project Ideas
As the procedure is now written, a square is drawn as a diamond. Can you figure out a way to point t1 to the heading needed so that squares, hexagons, and octagons are drawn with a flat top and bottom? (Hint: Consider how much t1 turns before moving out to the next vertex: 360 / #sides ... What portion of this angle does the turtle need to turn to "straighten out" a polygon with an even number of sides?)
