Goal: The turtle does the math to make polygons.
Vocabulary: / (division sign), setpensize
repeat #sides [fd howbig rt 360 / #sides]
In this project, the turtle will always turn exactly the right amount to make regular polygons with equal sides and equal angles.
- Make a new slider called #howthick. Set its minimum to 1 and its maximum to 30 (or another number of your choosing, less than 30).
Revise the polygon procedure as shown.
- The turtle needs to turn 360 degrees in all to draw a polygon.
Rt 360 / #sides means, "Turn right 360 degrees divided by the number on the #sides slider."
Notice that the polygon procedure uses #sides twice in one command.
- Setpensize howthick means, "Set the thickness of the turtle's pen to the number on the howthick slider." Every turtle starts out with a pensize of 1. You can choose any pensize up to 30
- We don't need the angle slider any more. The turtle will do the math for us to figure out the angles we need. You may remove this slider. (Right-click/ctrl-click and select Cut.)
Set the #sides and howbig sliders to draw a variety of polygons. What settings draw the largest possible polygon that does not "wrap" (that does not go off the edge of the project's page)?
At what setting on the #sides slider does the polygon begin to resemble a circle more than a polygon? (Let's call this the "first circle" setting.) Change the settings on the howbig and howthick sliders to see their effect on the "first circle" setting.
On Your Own - Project Ideas
Use the method for creating manysquares (see project 5 in the squares folder) to create a manypolygons procedure.