The Moon’s surface is covered with thousands of craters. These are caused by asteroids and meteorites colliding with the lunar surface. In this challenge, we will use Python Turtle to create a drawing of the Moon with a random selection of craters.
This challenge consists of randomly positioning craters of various size (radius) on the surface of the Moon. Generating random (x,y) coordinates is fairly straight forward, however the challenge is to ensure that the craters fit within the disc representing the Moon:
We have started the code for you. You can complete the code in the first tab below. Alternatively you can compare two different approaches used to solve this challenge:
- Solution 1: Using polar coordinates and trigonometric formulas (SOHCAHTOA)
- Solution 2: Using Cartesian coordinates and Pythagoras’ Theorem
Though this approach works, it tends to generate a higher density of craters towards the centre of the disc representing the Moon.
Our second solution, fully based on Cartesian coordinates solves this problem.
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area