diff --git a/objs/halley_comet.py b/objs/halley_comet.py index c19b3e8384d40eaa16fdba3a089502661eebb72a..d6eacddbdab974308f2c441a69062e8bac23aefc 100644 --- a/objs/halley_comet.py +++ b/objs/halley_comet.py @@ -18,6 +18,7 @@ class HalleComet(RockSnow): 远日点: 35.1 AU(2023年12月9日) 近日点: 0.586 AU 上次通过近日点:1986年2月9日 下次通过近日点:2061年7月28日 平均密度: 0.6(估计的范围在0.2至1.5g/cm) + 均密度: 1 g/cm³ -> 1✕10³ kg/m³ 来源:https://www.cgmodel.com/model/500318.html """ diff --git a/sim_scenes/solar_system/halley_comet_sim.py b/sim_scenes/solar_system/halley_comet_sim.py index bd7f7793883d50b093c9dfa6ccb03ab3ea3e5d6d..e4071093201aa2e137b93ee9a99a8d205c55a5a4 100644 --- a/sim_scenes/solar_system/halley_comet_sim.py +++ b/sim_scenes/solar_system/halley_comet_sim.py @@ -182,7 +182,7 @@ class HalleyCometSim: set_solar_system_celestial_position(self.bodies, t, False) def create_year_label(self, trail, year, halley_comet_pos): - label = create_label(trail, label=year, pos=(0,0,0), color=(255, 255, 255), scale=40, alpha=1.0) + label = create_label(trail, label=year, pos=(0, 0, 0), color=(255, 255, 255), scale=40, alpha=1.0) # label.udpate label.set_light_off() @@ -213,14 +213,41 @@ class HalleyCometSim: last_trail.entity_infos["time"] = dt.strftime("%Y-%m-%d") # print(last_trail.entity_infos) + pos = self.halley_comet.planet.position + + import copy + if not hasattr(self, "last_year"): - self.create_year_label(last_trail, year, self.halley_comet.planet.position) + self.create_year_label(last_trail, year, pos) elif self.last_year != year: - self.create_year_label(last_trail, year, self.halley_comet.planet.position) + if not hasattr(self, "last_label_pos"): + self.create_year_label(last_trail, year, pos) + self.last_label_pos = copy.deepcopy(self.halley_comet.position) + else: + # 防止标签非常紧密 + d = calculate_distance(self.halley_comet.position, self.last_label_pos) + if d > AU: + self.create_year_label(last_trail, year, pos) + self.last_label_pos = copy.deepcopy(self.halley_comet.position) self.last_year = year + # 哈雷彗星离太阳最近的点称为 "perihelion of Halley's Comet"(近日点:comet_peri), + + if not hasattr(self, "comet_peri"): + self.comet_peri = d_sun + elif d_sun < self.comet_peri: + self.comet_peri = d_sun + + # 哈雷彗星离太阳最远的点称为 "aphelion of Halley's Comet"(远日点) + if not hasattr(self, "comet_aphel"): + self.comet_aphel = d_sun + elif d_sun > self.comet_aphel: + self.comet_aphel = d_sun + panel_text = "哈雷彗星:\n距离太阳:%.3f AU" % (d_sun / AU) + panel_text += "\n离日最远:%.3f AU" % (self.comet_aphel / AU) + 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 @@ -288,4 +315,4 @@ if __name__ == '__main__': show_control_info=False, timer_enabled=True, show_grid=False - ) \ No newline at end of file + ) diff --git a/simulators/ursina/entities/body_trail.py b/simulators/ursina/entities/body_trail.py index c1b36ab46db0f2a7560194963a27f2b0e3637f4e..1b5b6e7d30b7050a5018d03d60b8fc8be4746822 100644 --- a/simulators/ursina/entities/body_trail.py +++ b/simulators/ursina/entities/body_trail.py @@ -52,9 +52,13 @@ class BodyTrail(Entity): # self.origin_color = self.color self.origin_alpha = self.alpha - if len(self.children) > 0: - for c in self.children: + if not hasattr(self, "info_entities"): + self.info_entities = [] + + if len(self.info_entities) > 0: + for c in self.info_entities: destroy(c) + self.info_entities = [] # self.color = self.origin_color self.alpha = self.origin_alpha return @@ -79,28 +83,42 @@ class BodyTrail(Entity): acc_info = "%.2fm/s²" % (acc_m) elif acc_m >= 0.00001: acc_info = "%.2fmm/s²" % (acc_m * 1000) - # elif acc_m >= 0.00000001: - # acc_info = "%.2fμm/s²" % (acc_m * 1000 * 1000) + elif acc_m >= 0.00000001: + acc_info = "%.2fμm/s²" % (acc_m * 1000 * 1000) else: acc_info = "0m/s²" if vel_value < 0.00000001: - create_label(parent=self, label=vel_info, pos=Vec3(-0.5, -0.5, -0.5), color=color.red).set_light_off() + label = create_label(parent=self, label=vel_info, pos=Vec3(-0.5, -0.5, -0.5), + color=color.red).set_light_off() + self.info_entities.append(label) + # label.infos = vel_info # v_text.parent = self # # v_arrow.enabled = False # # v_line.enabled = False else: v_arrow, v_line, v_text = create_arrow_line((0, 0, 0), tuple(vel_direction), parent=self, label=vel_info, color=color.red, alpha=0.8, arrow_scale=0.5) - - if acc_m < 0.00001: - create_label(parent=self, label=acc_info, pos=Vec3(0.5, 0.5, 0.5), color=color.green).set_light_off() + # v_arrow.infos = vel_info + # v_line.infos = vel_info + # v_text.infos = vel_info + self.info_entities += v_arrow, v_line, v_text + + if acc_m < 0.00000001: + label = create_label(parent=self, label=acc_info, pos=Vec3(0.5, 0.5, 0.5), + color=color.green).set_light_off() + self.info_entities.append(label) + # label.infos = acc_info # a_text.parent = self # a_arrow.enabled = False # a_line.enabled = False else: a_arrow, a_line, a_text = create_arrow_line((0, 0, 0), tuple(acc_direction), parent=self, label=acc_info, color=color.green, alpha=0.8, arrow_scale=0.5) + self.info_entities += a_arrow, a_line, a_text + # a_arrow.infos = acc_info + # a_line.infos = acc_info + # a_text.infos = acc_info class BodyTrailLine_OK(Entity):