From 4052b98a745f398b7578df6402a05cdc3498af1f Mon Sep 17 00:00:00 2001 From: march3 Date: Sat, 8 Apr 2023 12:49:54 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?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 --- common/consts.py | 4 ++++ sim_scenes/earth/free_fall_of_ball.py | 15 +++++++++------ sim_scenes/fiction/fixed_stars_2.py | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/common/consts.py b/common/consts.py index 129353e..0d90941 100644 --- a/common/consts.py +++ b/common/consts.py @@ -29,6 +29,10 @@ AU: float = 149597870.700 """ G: float = 6.67e-11 +""" +一分钟多少秒 +""" +SECONDS_PER_MINUTE = 60 """ 一小时多少秒 """ diff --git a/sim_scenes/earth/free_fall_of_ball.py b/sim_scenes/earth/free_fall_of_ball.py index 385a90f..7017ea5 100644 --- a/sim_scenes/earth/free_fall_of_ball.py +++ b/sim_scenes/earth/free_fall_of_ball.py @@ -1,30 +1,33 @@ # -*- coding:utf-8 -*- -# title :地月场景模拟 -# description :地月场景模拟 +# title :自由落地模拟 +# description :自由落地模拟 # author :Python超人 # date :2023-02-11 # link :https://gitcode.net/pythoncr/ # python_version :3.8 # ============================================================================== from bodies import Moon, Earth, Body -from common.consts import SECONDS_PER_HOUR, SECONDS_PER_HALF_DAY, SECONDS_PER_DAY, SECONDS_PER_WEEK, SECONDS_PER_MONTH +from common.consts import SECONDS_PER_HOUR, SECONDS_PER_MINUTE from sim_scenes.func import mayavi_run, ursina_run if __name__ == '__main__': """ - 地球、6个月球 + 自由落地模拟 """ # 地球在中心位置 e = Earth(init_position=[0, 0, 0], size_scale=1, texture="earth_hd.jpg", init_velocity=[0, 0, 0]) bodies = [ e, - Moon(name='小球', mass=4.4e18, init_position=[0, e.raduis + 500, 0], init_velocity=[0, 0, 0]), # 球在地球上面500km + Moon(name='小月球', mass=4.4e18, + init_position=[0, e.raduis + 500, 0], # 球在地面上 500km + init_velocity=[0, 0, 0]), ] # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, 60, position=(0, e.raduis + 500, -4500), + ursina_run(bodies, SECONDS_PER_MINUTE, # 一秒相当于一分钟 + position=(0, e.raduis + 500, -4500), show_trail=True, show_timer=True, view_closely=0.001) diff --git a/sim_scenes/fiction/fixed_stars_2.py b/sim_scenes/fiction/fixed_stars_2.py index 183e011..51e221c 100644 --- a/sim_scenes/fiction/fixed_stars_2.py +++ b/sim_scenes/fiction/fixed_stars_2.py @@ -58,5 +58,5 @@ if __name__ == '__main__': # M:摄像机移动加速 N:摄像机移动减速 # position = (左-右+、上+下-、前+后-) ursina_run(bodies, SECONDS_PER_WEEK, - position=(0, 100000, -AU / 500), + position=(0, 30000, -AU / 500), show_name=True, bg_music="sounds/universe_03.mp3") -- GitLab