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 Expert 7
Download
6 KB


Goal:   Circumscribe a circle around a polygon.


Screenshot


Code
Project Map

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

to circle-a-polygon
polygon
t1, pu seth 0
setc circolor
setpensize 2
repeat 360 [pu fd howbig rt 90 pd fd 1 bk 1 lt 90 pu bk howbig rt 1]
end

to reset
ask [t1 t2] [home seth 0]
cg
end



Notes

This project draws a circle whose radius is howbig.   The radius is the same length as the distance from the center point to each vertex of the polygon.   If the polygon is drawn with a thin line, the circle will appear to circumscribe it.   (This means the circle surrounds the polygon, touching the point of each vertex.)   If the lines are thick, the circle will pass through the middle of each thick vertex.

  1. Add an extra slider and name it circolor so that you can set the polygon and circle to two different colors.  

  2. In the circle-a-polygon procedure, the method for drawing a circle is to build it dot by dot from the center point.   The turtle starts at the center point and moves out to the edge of the circle with its pen up, then turns right 90 degrees, draws a line segment that is only one pixel long, turns left 90 degrees, puts its pen up again, backs up to the center point, and turns one degree.   It repeats this process 360 times, drawing 360 tiny line segments to form a circle.   If the radius of the circle is large, then the circle will appear dotted instead of solid.   (If the howbig slider is set too high, some shapes drawn by the polygon procedure may wrap instead of forming regular polygons, and the turtle will not be able to circumscribe the shape.   Set the howbig slider small enough to draw a regular polygon.)




What If?
Try different settings for howbig and howthick.   (What happens to the circle if the polygon "wraps" beyond the project page border? What is the largest howbig setting that fits?)


Challenge
Can you revise the circle-a-polygon procedure so that the circle is drawn with fewer line segments (perhaps 180 or 90 instead of 360)? What else do you need to adjust besides the repeat command?


On Your Own - Project Ideas
Can you revise the procedure so that the circle is drawn larger and does not touch the polygon at all?





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