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. (The text box name must be only one word.) 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?
|