From 956a5fa4b77f0dfbcfc2ec1b8fb4ab9ad2670245 Mon Sep 17 00:00:00 2001 From: march3 Date: Thu, 13 Apr 2023 14:26:27 +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 --- sim_scenes/solar_system/speed_of_light.py | 4 +- .../solar_system/transit_of_venus_mercury.py | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 sim_scenes/solar_system/transit_of_venus_mercury.py diff --git a/sim_scenes/solar_system/speed_of_light.py b/sim_scenes/solar_system/speed_of_light.py index 4643c53..32c4afe 100644 --- a/sim_scenes/solar_system/speed_of_light.py +++ b/sim_scenes/solar_system/speed_of_light.py @@ -13,8 +13,8 @@ from sim_scenes.solar_system.speed_of_light_init import SpeedOfLightInit # TODO: 三种不同的摄像机视角 camera_follow_light = None # 摄像机固定,不会跟随光 # camera_follow_light = 'ForwardView' # 摄像机跟随光,方向是向前看 -# camera_follow_light = 'SideView' # 摄像机跟随光,方向是侧面看 -# camera_follow_light = 'SideViewActualSize' # 摄像机跟随光,方向是侧面看,天体是实际大小 +# camera_follow_light = 'SideView' # 摄像机跟随光,方向是从侧面看 +# camera_follow_light = 'SideViewActualSize' # 摄像机跟随光,方向是从侧面看,天体是实际大小 # 实例化一个初始化对象(订阅事件,记录到达每个行星所需要的时间) init = SpeedOfLightInit(camera_follow_light) diff --git a/sim_scenes/solar_system/transit_of_venus_mercury.py b/sim_scenes/solar_system/transit_of_venus_mercury.py new file mode 100644 index 0000000..68ab862 --- /dev/null +++ b/sim_scenes/solar_system/transit_of_venus_mercury.py @@ -0,0 +1,43 @@ +# -*- coding:utf-8 -*- +# title :水星、金星凌日 +# description :水星、金星凌日 +# author :Python超人 +# date :2023-02-11 +# link :https://gitcode.net/pythoncr/ +# python_version :3.8 +# ============================================================================== +from bodies import Sun, Mercury, Venus, Earth +from common.consts import SECONDS_PER_WEEK, SECONDS_PER_DAY, SECONDS_PER_HOUR, AU +from sim_scenes.func import mayavi_run, ursina_run, camera_look_at +from simulators.ursina.entities.body_timer import TimeData +from simulators.ursina.ursina_event import UrsinaEvent + +if __name__ == '__main__': + # 水星、金星凌日 + earth = Earth(name="地球") + sun = Sun(name="太阳", size_scale=5e1) # 太阳放大 20 倍 + bodies = [ + sun, + Mercury(name="水星", + init_position=[0.384 * AU, 0, 0], + init_velocity=[0, 0, 47.87], + size_scale=5e1), # 水星放大 10 倍,距离保持不变 + Venus(name="金星", + init_position=[0.721 * AU, 0, 0], + init_velocity=[0, 0, 35], + size_scale=5e1) # 金星放大 10 倍,距离保持不变 + ] + + + def on_ready(): + camera_look_at(sun, rotation_x=None, rotation_y=None, rotation_z=0) + pass + + + UrsinaEvent.on_ready_subscription(on_ready) + + # 使用 ursina 查看的运行效果 + # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 + # position = 左-右+、上+下-、前+后- + ursina_run(bodies, SECONDS_PER_DAY * 3, + position=earth.init_position) -- GitLab