Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Moon, Earth, Sun orbital simulation
- # using Turtle graphics
- # Juhani Kaukoranta 8th June 2018
- from turtle import Turtle
- import math
- # Moon, Sun, Earth initiation
- Moon = Turtle()
- Moon.hideturtle()
- Earth = Turtle()
- Earth.hideturtle()
- Sun = Turtle()
- Sun.color("yellow")
- Sun.begin_fill()
- Sun.hideturtle()
- Sun.circle(10)
- Sun.end_fill()
- Moon.color("blue")
- Moon.pensize(2)
- Earth.color("green")
- Earth.pensize(6)
- Moon.up()
- Moon.setposition(230,0)
- Moon.down()
- Earth.up()
- Earth.setposition(200,0)
- Earth.down()
- # Earth, Sun orbit calculations
- for i in range (0,360):
- xM = 200*math.cos(i*math.pi/180.0)+30*math.cos(13.4*i*math.pi/180.0)
- yM = 200*math.sin(i*math.pi/180.0)+30*math.sin(13.4*i*math.pi/180.0)
- Moon.setposition(xM,yM)
- xE = 200*math.cos(i*math.pi/180.0)
- yE = 200*math.sin(i*math.pi/180.0)
- Earth.setposition(xE,yE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement