Showing posts with label generalized regular polygon. Show all posts
Showing posts with label generalized regular polygon. Show all posts

## Wednesday, July 1, 2015

### How to Program a Circle in Scratch - Part 1

Scratch does not have a circle block. For example, there is not a block that lets you define where to place the center of a circle, and with what radius, that will draw a circle or perhaps the length of arc of a circle you would like Scratch to draw. But, with a bit of circle geometry and a dash of simple coding, it’s easy to build such a block. But it takes a series of short, easy to make jumps, not a long leap to get to such a block. So, let’s make the first jump, into the problem and, through a series of posts, we will soon enough complete the long jump.
Scratch may not have a circle block but it does have a [move ____steps] block and a [turn (rt) ____degrees] block. These two blocks make it is easy to draw a regular polygon with Scratch. This code creates an 18-sided polygon that starts and stops at (0, 0).
A regular polygon with 18 sides is not far from looking circular. The red-shaded portion in this graphic shows how small the difference is.

The number of sides of a regular polygon does not have to be too large for it to look very much like a circle. A regular polygon with 36 sides can hardly be seen as anything but a circle as can be seen in the following graphic where Scratch has drawn a regular polygon with 36 sides.
To draw a circle we can first draw a regular polygon with a sufficient number of sides to make the polygon approach a circle to the point that there is essentially no difference between the two. Then, if the program can set the radius, we can draw a circle of any size at a given point! Therefore, my next post will go through, step-by-step, how to program a generalized regular polygon script in Scratch.This is the first hop so remember it will take three or four hops to complete the leap.