From fa78081b3707458f3b56bbb487a54f8b01dc9bb2 Mon Sep 17 00:00:00 2001 From: march3 Date: Tue, 21 Mar 2023 22:32:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=AA=E9=98=B3=E7=B3=BB=E4=B8=89=E4=BD=93?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/func.py | 2 +- scenes/gravity_slingshot.py | 2 +- scenes/sun_earth.py | 5 ++--- scenes/sun_earth_jupiter.py | 2 +- scenes/three_body_03.py | 2 +- scenes/tri_bodies_sim_perfect.py | 2 +- scenes/two_body_01.py | 2 +- scenes/ursina_json_sim.py | 3 ++- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scenes/func.py b/scenes/func.py index bc43a1d..e91a508 100644 --- a/scenes/func.py +++ b/scenes/func.py @@ -83,7 +83,7 @@ def ursina_run(bodies, body_sys = System(bodies) if save_as_json is not None: try: - body_sys.save_to_json(save_as_json, {"dt": dt, "position": position}) + body_sys.save_to_json(save_as_json, {"dt": dt, "position": position, "show_trail": show_trail}) print(f"{save_as_json} 文件生成成功!") except Exception as e: print(f"{save_as_json} 文件生成失败!" + str(e)) diff --git a/scenes/gravity_slingshot.py b/scenes/gravity_slingshot.py index 17b58b3..6c41497 100644 --- a/scenes/gravity_slingshot.py +++ b/scenes/gravity_slingshot.py @@ -32,4 +32,4 @@ if __name__ == '__main__': # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_MONTH, position=(0, AU, -3 * AU)) + ursina_run(bodies, SECONDS_PER_MONTH, position=(0, AU, -3 * AU), show_trail=True) diff --git a/scenes/sun_earth.py b/scenes/sun_earth.py index 982bd67..8b9f346 100644 --- a/scenes/sun_earth.py +++ b/scenes/sun_earth.py @@ -15,8 +15,7 @@ if __name__ == '__main__': 太阳、地球 Sirius(size_scale=0.2, init_position=[0, 0, 0]), """ bodies = [ - Sirius(size_scale=2e1,init_position=[0,0,0]), - Sun(size_scale=5e1,init_position=[0,0,0]), # 太阳放大 50 倍 + Sun(size_scale=5e1), # 太阳放大 50 倍 Earth(size_scale=2e3, distance_scale=1), # 地球放大 2000 倍,距离保持不变 ] @@ -26,4 +25,4 @@ if __name__ == '__main__': # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_WEEK, position=(0, AU, -3 * AU)) + ursina_run(bodies, SECONDS_PER_WEEK, position=(0, AU, -3 * AU), show_trail=True) diff --git a/scenes/sun_earth_jupiter.py b/scenes/sun_earth_jupiter.py index 2b8d2ea..54c99e3 100644 --- a/scenes/sun_earth_jupiter.py +++ b/scenes/sun_earth_jupiter.py @@ -26,4 +26,4 @@ if __name__ == '__main__': # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_WEEK, position=(0, AU, -3 * AU)) + ursina_run(bodies, SECONDS_PER_WEEK, position=(0, AU, -3 * AU), show_trail=True) diff --git a/scenes/three_body_03.py b/scenes/three_body_03.py index 82f849b..09715ce 100644 --- a/scenes/three_body_03.py +++ b/scenes/three_body_03.py @@ -59,4 +59,4 @@ if __name__ == '__main__': # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_YEAR, position=(3 * AU, 3 * AU, -20 * AU)) + ursina_run(bodies, SECONDS_PER_YEAR, position=(3 * AU, 3 * AU, -20 * AU), show_trail=True) diff --git a/scenes/tri_bodies_sim_perfect.py b/scenes/tri_bodies_sim_perfect.py index c4e9287..83a5fa1 100644 --- a/scenes/tri_bodies_sim_perfect.py +++ b/scenes/tri_bodies_sim_perfect.py @@ -53,4 +53,4 @@ if __name__ == '__main__': # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_YEAR, position=(3 * AU, AU, -4 * AU)) + ursina_run(bodies, SECONDS_PER_YEAR, position=(-2 * AU, AU, -5 * AU), show_trail=True) diff --git a/scenes/two_body_01.py b/scenes/two_body_01.py index 16654b4..305fda6 100644 --- a/scenes/two_body_01.py +++ b/scenes/two_body_01.py @@ -33,4 +33,4 @@ if __name__ == '__main__': # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_YEAR, position=(0, 2 * AU, -5 * AU)) \ No newline at end of file + ursina_run(bodies, SECONDS_PER_YEAR, position=(0, 2 * AU, -5 * AU), show_trail=True) \ No newline at end of file diff --git a/scenes/ursina_json_sim.py b/scenes/ursina_json_sim.py index 254f3e4..72677ae 100644 --- a/scenes/ursina_json_sim.py +++ b/scenes/ursina_json_sim.py @@ -29,9 +29,10 @@ if __name__ == '__main__': dt = params["dt"] if "dt" in params else SECONDS_PER_YEAR position = params["position"] if "position" in params else (0, 0, 0) + show_trail = params["show_trail"] if "show_trail" in params else True # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- json_file = None # 指定 json_file 保存路径,则会将模拟环境天体数据保存到该json文件中 - ursina_run(bodies, dt, position=position, save_as_json=json_file) + ursina_run(bodies, dt, position=position, save_as_json=json_file, show_trail=show_trail) -- GitLab