Write a program that draws a circle, with the given centre point x:0, y:0, and its radius equal to 100 steps.
You can use the same method as the "Draw a 360-sided polygon" challenge, but this time you will need to work out how long each side is based on the circumference of the circle, and you'll need to work out the circumference from the radius.
Testing examples:
There are no testing examples for this challenge.
Languages
Scratch
What it should look like
Click on the green flag to see the expected output of your program.
The radius of a circle is the distance of its centre to the edge of the circle.
The circumference is the distance around a circle (its perimeter) and is equal to 2πr where r is the radius of the circle.
To be able to draw the circle right in the centre, you will need to set your sprite to point in the right direction.
To set the direction of the current sprite use the block under the “motion” script.
Extra challenge #1:
Write a program that works for any radius.
That means that it takes a radius as the input then draws a circle with the given radius, and then displays the circumference as the output.
Extra challenge #2:
Write a program that takes a circumference as the input then draws a circle with the given circumference and then displays the radius as the output.
Extra challenge #3:
[This requires advanced maths, but is a good challenge for a student who is familiar with Pythagoras' theorem] Draw a Circle Using Pythagoras’ Theorem.
The diagram above shows a circle (radius 100) drawn using the Pythagoras’ Theorem method.
(Note: The red triangle inside the circle is only to show the calculation and does not need to be drawn).
You can use Pythagoras’ Theorem (in any right-angle triangle, the square of the side opposite the right angle is equal to the sum of the squares of the other two sides so here x2+y2=radius2) to draw a circle.
We can do this by rearranging the formula to solve for y like this:
y2=radius2−x2y=sqrt(radius2−x2)
We then calculate y using a range of values for x (i.e. from 0 to ±radius). Your programming language will probably only give you the positive square root, so you will also need to plot the negative of y.
This definition is not available in English, sorry!