From cf06389d90b8943f9900cbce1f81986adf32f98c Mon Sep 17 00:00:00 2001 From: march3 Date: Sat, 24 Jun 2023 20:52:15 +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/fiction/earth_orbit_stopped.py | 43 ++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/sim_scenes/fiction/earth_orbit_stopped.py b/sim_scenes/fiction/earth_orbit_stopped.py index cde1d41..8d5a612 100644 --- a/sim_scenes/fiction/earth_orbit_stopped.py +++ b/sim_scenes/fiction/earth_orbit_stopped.py @@ -33,7 +33,7 @@ class EarthOrbitStoppedSim: def __init__(self): self.sun = Sun(init_position=[0, 0, 0], size_scale=1) - self.earth = Earth(init_position=[0, 0, -AU], + self.earth = Earth(init_position=[0, 0, -AU], texture="earth2.jpg", init_velocity=[0, self.EARTH_INIT_VELOCITY, 0], size_scale=1).set_light_disable(True) @@ -43,7 +43,7 @@ class EarthOrbitStoppedSim: self.mercury = Mercury(name="水星", # init_position=[0, 0, -self.mercury_radius], # 和地球插肩而过的位置,用于找到下面的速度 init_position=[49311300., 0, 28075956.], # 设置的初始位置和初始速度使得与地球插肩而过 - init_velocity=[-24.307, 0, 41.9264], + init_velocity=[-24.28, 0, 41.91], size_scale=1).set_light_disable(True) # 金星: [-98608848. 0. -42909512.] [-13.869937 0. 32.247845] self.venus = Venus(name="金星", @@ -106,16 +106,43 @@ class EarthOrbitStoppedSim: application.pause() return - if time_data.days in [40, 41]: - self.venus_orbit_line.enabled = True - else: - self.venus_orbit_line.enabled = False + slow_speed_ranges = [ + (41.2, 41.35, 0.01), # (40, 41.2, 0.1), (41.2, 42.2, 0.1), (39, 40.2, 0.5), (42, 43, 0.5), + (56.85, 57.05, 0.01), # (55, 56.9, 0.1), (57, 58.05, 0.1), (54, 55.2, 0.5), (58.2, 59, 0.5), + (64.3, 67, 0.01), # (63, 64.4, 0.1), (64, 64.5, 0.5), + ] + + venus_range = slow_speed_ranges[0] + mercury_range = slow_speed_ranges[1] - if time_data.days in [56, 57]: + if mercury_range[0] - 2 < time_data.total_days < mercury_range[1]: self.mercury_orbit_line.enabled = True else: self.mercury_orbit_line.enabled = False + if venus_range[0] - 2 < time_data.total_days < venus_range[1]: + self.venus_orbit_line.enabled = True + else: + self.venus_orbit_line.enabled = False + + run_speed_factor = 2 + + for r in slow_speed_ranges: + if r[0] < time_data.total_days < r[1]: + run_speed_factor = r[2] + elif (r[0] - 2) < time_data.total_days < (r[1] + 5): + if time_data.total_days <= r[0]: + run_speed_factor = UrsinaConfig.run_speed_factor - 0.01 + if run_speed_factor < 0.01: + run_speed_factor = 0.01 + elif time_data.total_days >= r[1]: + run_speed_factor = UrsinaConfig.run_speed_factor + 0.05 + if run_speed_factor > 2: + run_speed_factor = 2 + break + + UrsinaConfig.run_speed_factor = run_speed_factor + if abs(self.earth.position[2]) < 0.721 * AU and not self.arrived_venus_orbit_line: self.arrived_venus_orbit_line = True msg = "地球在[%s]穿过金星轨道" % time_data.time_text @@ -185,6 +212,6 @@ if __name__ == '__main__': # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- # position=(0, 0, 0) 的位置是站在地球视角,可以观看月相变化的过程 - ursina_run(sim.bodies, SECONDS_PER_DAY, position=(0, 0.0001 * AU, -0.2 * AU), + ursina_run(sim.bodies, SECONDS_PER_DAY, position=(0, 0.0001 * AU, -0.8 * AU), show_timer=True, show_grid=True) -- GitLab