Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NOTE! use (7910000000000,7910000000000,7910000000000) to see entire system, delete one zero from each dimension to see just the center of solar system
- from visual import *
- scene=display(title="Universe!",x=0, y=0, width=800,
- height=600,range=vector(7910000000000,7910000000000,7910000000000),
- center=vector(0,0,0))
- t = 0.0
- dt = 1*10**5 #change in time
- #initial positions of planets and sun
- sEarth = vector(150000000000.0,0.0,0.0)
- sMoon = vector(sEarth.x + 384472282.0, 0.0, 0.0)
- sSun = vector(0.0,0.0,0.0)
- sMars = vector(228000000000,0.0,0.0)
- sVenus = vector(108000000000,0.0,0.0)
- sUranus = vector(2880000000000,0.0,0.0)
- sNeptune = vector(4500000000000,0.0,0.0)
- sPluto = vector(5910000000000,0.0,0.0)
- sJupiter = vector(779000000000,0.0,0.0)
- sSaturn = vector(1430000000000,0.0,0.0)
- sMercury = vector(57000000000,0.0,0.0)
- #initial velocities in m/s of the planets orbiting around the sun
- vEarth = 30000
- vMoon = 1023.41
- vSun = 0
- vMars = 24077
- vVenus = 35020
- vUranus = 6810
- vNeptune = 5430
- vPluto = 4670
- vJupiter = 13070
- vSaturn = 9690
- vMercury = 47870
- rMoon = 384472282 #distance between earth and moon in m
- #distance between the sun and planets in m
- rEarth = 150000000000
- rSun = 0
- rMars = 228000000000
- rVenus = 108000000000
- rUranus = 2880000000000
- rNeptune = 4500000000000
- rPluto = 5910000000000
- rJupiter = 779000000000
- rSaturn = 1430000000000
- rMercury = 57000000000
- #object creation / making the planets and sun
- Moon=sphere(pos=sMoon,radius=4000000,color=color.white, make_trail=True, trail_type="points", interval=10, retain=15)
- Earth=sphere(pos=sEarth, radius=90000000, material=materials.earth)
- Sun=sphere(pos=sSun,radius=695700000,color=color.orange, make_trail=True, trail_type="points", interval=10, retain=15)
- Mars=sphere(pos=sMars,radius=3397000,color=(1,0.7,0.2), make_trail=True, trail_type="points", interval=10, retain=15)
- Venus=sphere(pos=sVenus,radius=6052000,color=color.red, make_trail=True, trail_type="points", interval=10, retain=15)
- Uranus=sphere(pos=sUranus,radius=25559000,color=color.blue, make_trail=True, trail_type="points", interval=10, retain=15)
- Neptune=sphere(pos=sNeptune,radius=24766000,color=(1,0,1), make_trail=True, trail_type="points", interval=10, retain=15)
- Pluto=sphere(pos=sPluto,radius=1150000,color=(0.7,0.5,0.5), make_trail=True, trail_type="points", interval=10, retain=15)
- Jupiter=sphere(pos=sJupiter,radius=71492000,color=color.yellow, make_trail=True, trail_type="points", interval=10, retain=15)
- Saturn=sphere(pos=sSaturn,radius=60268000,color=(0.5,0,0.2), make_trail=True, trail_type="points", interval=10, retain=15)
- Mercury=sphere(pos=sMercury,radius=2440000,color=(0.5,0.5,0.5), make_trail=True, trail_type="points", interval=10, retain=15)
- while t < 500000000000: #time for program to run, right now just an arbitrarily large number
- rate(100) # Sets fps to 100, 400 works even better (especially with higher dts) if the computer can handle it
- #the following calculates the position of each planet and updates their position
- sMoon = (cos(vMoon*t/rMoon)*rMoon +cos(vEarth*t/rEarth)*rEarth ,sin(vMoon*t/rMoon)*rMoon+sin(vEarth*t/rEarth)*rEarth,0) #calculates the position of the moon
- Moon.pos=sMoon #updating moon's position
- sEarth = (cos(vEarth*t/rEarth)*rEarth,sin(vEarth*t/rEarth)*rEarth,0)
- Earth.pos = sEarth
- sMars = (cos(vMars*t/rMars)*rMars,sin(vMars*t/rMars)*rMars,0)
- Mars.pos = sMars
- sVenus = (cos(vVenus*t/rVenus)*rVenus,sin(vVenus*t/rVenus)*rVenus,0)
- Venus.pos = sVenus
- sUranus = (cos(vUranus*t/rUranus)*rUranus,sin(vUranus*t/rUranus)*rUranus,0)
- Uranus.pos = sUranus
- sNeptune = (cos(vNeptune*t/rNeptune)*rNeptune,sin(vNeptune*t/rNeptune)*rNeptune,0)
- Neptune.pos = sNeptune
- sPluto = (cos(vPluto*t/rPluto)*rPluto,sin(vPluto*t/rPluto)*rPluto,0)
- Pluto.pos = sPluto
- sJupiter = (cos(vJupiter*t/rJupiter)*rJupiter,sin(vJupiter*t/rJupiter)*rJupiter,0)
- Jupiter.pos = sJupiter
- sSaturn = (cos(vSaturn*t/rSaturn)*rSaturn,sin(vSaturn*t/rSaturn)*rSaturn,0)
- Saturn.pos = sSaturn
- sMercury = (cos(vMercury*t/rMercury)*rMercury,sin(vMercury*t/rMercury)*rMercury,0)
- Mercury.pos = sMercury
- t = t + dt #updating time
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement