# -*- coding:utf-8 -*- # title :太阳系中消失的行星 # description :太阳系中消失的行星 # author :Python超人 # date :2023-12-05 # link :https://gitcode.net/pythoncr/ # python_version :3.9 # ============================================================================== from bodies import Sun, Mercury, Venus, Earth, Mars, Moon, Ceres, Jupiter, Saturn, Uranus, Neptune, Pluto, Asteroids from common.consts import SECONDS_PER_WEEK, SECONDS_PER_DAY, SECONDS_PER_MONTH, SECONDS_PER_YEAR, AU from sim_scenes.func import mayavi_run, ursina_run, create_sphere_sky from sim_scenes.universe_sim_scenes import UniverseSimScenes from simulators.ursina.ursina_event import UrsinaEvent if __name__ == '__main__': sun = Sun(size_scale=0.4e2) asteroids = Asteroids(size_scale=1.08e2, parent=sun) # 小行星模拟(仅 ursina 模拟器支持) moon = Moon(size_scale=3e3, init_position=[0, 0, (0.4 + 2.4) * AU]) ceres = Ceres(size_scale=3e3) jupiter = Jupiter(size_scale=0.68e3) saturn = Saturn(size_scale=0.68e3) bodies = [ sun, # 太阳放大 80 倍 Mercury(size_scale=3e3), # 水星放大 4000 倍 Venus(size_scale=3e3), # 金星放大 4000 倍 Earth(size_scale=3e3), # 地球放大 4000 倍 Mars(size_scale=3e3), # 火星放大 4000 倍 asteroids, moon, ceres, # Earth(size_scale=3e3, init_position=[0, 0, (2.17) * AU]), # 地球放大 4000 倍 # Earth(size_scale=3e3, init_position=[0, 0, (3.64) * AU]), # 地球放大 4000 倍 jupiter, # 木星放大 680 倍 saturn, # 土星放大 680 倍 Uranus(size_scale=0.8e3), # 天王星放大 800 倍 Neptune(size_scale=1e3), # 海王星放大 1000 倍 ] # 水星 0.4AU # 金星 0.4+0.3 AU # 地球 0.4+0.6 AU # 火星 0.4+1.2 AU # 木星 0.4+4.8 AU # 土星 0.4+9.6 AU # 天王星 0.4+19.2 AU # d = (n+4)/10 # an = 0.4+0.3×(2n-2) planet_no = -1 for idx, body in enumerate(bodies): if isinstance(body, Asteroids): continue body.rotation_speed = 0 planet_no += 1 # body.init_velocity = [0, 0, 0] # an = 0.4 + 0.3 * pow(2,idx) # an = (idx+4)/10 # 其中k=0,1,2,4,8,16,32,64,128 (0以后数字为2的2次方) # 行星 公式推得值 实测值 # 金星 0.7 0.72 # 地球 1 1 # 火星 1.6 1.52 # 谷神星 2.8 2.9 [1] # 木星 5.2 5.2 # 土星 10 9.54 # 天王星 19.6 19.18 # 海王星 38.8 30.06 # 冥王星 77.2 39.44 # 提丢斯-波得定则 # https://baike.baidu.com/item/%E6%8F%90%E4%B8%A2%E6%96%AF-%E6%B3%A2%E5%BE%97%E5%AE%9A%E5%88%99/859407 # 小行星 2.17-3.64天文单位 if planet_no == 0: continue elif planet_no == 1: an = 0.4 else: an = 0.4 + 0.3 * pow(2, planet_no - 2) print(body.name, an, body.position[2] / AU) def on_ready(): """ 事件绑定后,模拟器运行前会触发 @return: """ from ursina import camera # 创建天空 # create_sphere_sky(scale=20000) camera.clip_plane_near = 0.1 camera.clip_plane_far = 1000000 # camera.look_at(saturn.planet) # camera.look_at(sun.planet) # camera.rotation_y = 90 # UniverseSimScenes.show_grid_axises() asteroids.planet.enabled = False # moon.planet.enabled = False # 运行前会触发 on_ready UrsinaEvent.on_ready_subscription(on_ready) # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- ursina_run(bodies, SECONDS_PER_YEAR, gravity_works=False, position=(0, 2 * AU, -11 * AU), # position=(0, 20 * AU, 10 * AU), # position=(0, 20 * AU, 0), cosmic_bg='', show_grid=False)