diff --git a/sim_scenes/solar_system/halley_comet_sim.py b/sim_scenes/solar_system/halley_comet_sim.py index c4332258dddb1e360d8e16c57f73fcf0023e1d7a..af086bd31de12c8b019c0eb2640a0eeb00fc39c3 100644 --- a/sim_scenes/solar_system/halley_comet_sim.py +++ b/sim_scenes/solar_system/halley_comet_sim.py @@ -68,13 +68,12 @@ class HalleyCometSim(HalleyCometSimBase): # UrsinaConfig.trail_thickness_factor = 3 UrsinaConfig.trail_type = "line" UrsinaConfig.trail_thickness_factor = 3 - # UrsinaConfig.trail_length = 91 - UrsinaConfig.trail_length = 180 + UrsinaConfig.trail_length = 152 + # UrsinaConfig.trail_length = 180 UrsinaConfig.trail_factor = 3 # camera.clip_plane_near = 0.1 camera.clip_plane_far = 1000000 - # WorldGrid().draw_axises(10) application.time_scale = 5 @@ -122,6 +121,23 @@ class HalleyCometSim(HalleyCometSimBase): # label.udpate label.set_light_off() + def show_comet_trail(self, distance_sun): + d_au = distance_sun / AU + HIDE_DISTANCE = 1, 15 + MAX_ALPHA = 0.8 + if d_au >= HIDE_DISTANCE[1]: + alpha = 0 + elif HIDE_DISTANCE[1] > d_au > HIDE_DISTANCE[0]: + alpha = MAX_ALPHA - (d_au - HIDE_DISTANCE[0]) / (HIDE_DISTANCE[1] - HIDE_DISTANCE[0]) * MAX_ALPHA + else: + alpha = MAX_ALPHA + + if alpha > MAX_ALPHA: + alpha = MAX_ALPHA + + c = self.halley_comet.planet.children[0] + c.alpha = alpha + def on_timer_changed(self, time_data): """ @@ -162,7 +178,7 @@ class HalleyCometSim(HalleyCometSimBase): else: # 防止标签非常紧密 d = calculate_distance(self.halley_comet.position, self.last_label_pos) - if d > AU: + if d > 2 * AU: self.create_year_label(last_trail, year, pos) self.last_label_pos = copy.deepcopy(self.halley_comet.position) @@ -184,10 +200,14 @@ class HalleyCometSim(HalleyCometSimBase): self.comet_aphel = d_sun self.comet_aphel_dt = dt.strftime("%Y-%m-%d") + self.show_comet_trail(d_sun) + panel_text = "哈雷彗星:\n距离太阳:%.3f AU" % (d_sun / AU) - panel_text += "\n离日最远:%.3f AU(%s)" % (self.comet_aphel / AU, self.comet_aphel_dt) - panel_text += "\n离日最近:%.3f AU(%s)" % (self.comet_peri / AU, self.comet_peri_dt) - panel_text += "\n距离地球:%.3f AU" % (d_earth / AU) + # panel_text += "\n离日最远:%.3f AU(%s)" % (self.comet_aphel / AU, self.comet_aphel_dt) + panel_text += "\n离日最远:%.3f AU" % (self.comet_aphel / AU) + # panel_text += "\n离日最近:%.3f AU(%s)" % (self.comet_peri / AU, self.comet_peri_dt) + panel_text += "\n离日最近:%.3f AU" % (self.comet_peri / AU) + # panel_text += "\n距离地球:%.3f AU" % (d_earth / AU) velocity, _ = get_value_direction_vectors(self.halley_comet.velocity) panel_text += "\n当前速度:%.3f km/s" % velocity @@ -236,8 +256,8 @@ if __name__ == '__main__': params = HalleyCometParams( start_time='1982-09-24 00:00:00', # init_velocity=[-2.835, 4.72, 8.847], - init_velocity=[-2.826, 4.695, 8.86], - # init_velocity=[-2.836, 4.705, 8.85], + # init_velocity=[-2.826, 4.695, 8.86], + init_velocity=[-2.836, 4.705, 8.85], init_position=[0, -5 * AU, -10 * AU] )