#!/usr/bin/env python # coding: utf-8 # In[2]: # pip install ivisual from ivisual import * # In[3]: AU = 1.496e8 # km AU = 1e-2 * AU # so that we can see earth_radius = 6371 # km def orbit(bodies, radii, years, earth_years=10, _rate=24): for t in np.linspace(0, earth_years, earth_years * 365): rate(_rate) for body, radius, year in zip(bodies, radii, years): x = radius * np.cos(2*np.pi * t / year) y = radius * np.sin(2*np.pi * t / year) body.pos = (x, y, 0) # In[4]: canvas(width=900, height=600) # In[82]: sun = sphere(radius = 109 * earth_radius, color = color.red) earth = sphere(radius = earth_radius, color = color.blue, pos = (AU, 0, 0), make_trail=True) jupyter = sphere(radius = 10.5 * earth_radius, color = color.orange, pos = (5.2 * AU, 0, 0), make_trail=True) saturn = sphere(radius = 9.14 * earth_radius, color = color.cyan, pos = (9 * AU, 0, 0), make_trail=True) # In[83]: orbit(bodies=[earth, jupyter, saturn], radii=[AU, 5.2 * AU, 9 * AU], years=[1, 11.86, 29.5], earth_years=30, _rate=48) # In[ ]: # In[ ]: