From dbc2fd4740cc560cb797b3351fdf4acd354ea162 Mon Sep 17 00:00:00 2001 From: march3 Date: Fri, 30 Jun 2023 16:26:10 +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 --- bodies/habitable_zone.py | 4 ++-- .../solar_system_habitable_zone.py | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bodies/habitable_zone.py b/bodies/habitable_zone.py index ada43dc..65771d0 100644 --- a/bodies/habitable_zone.py +++ b/bodies/habitable_zone.py @@ -37,8 +37,8 @@ class HabitableZone(Body): "parent": parent } super().__init__(**params) - # 环状带(inner_radius, outer_radius, subdivisions) - self.torus_zone = 0.95, 2.4, 64 + # 环状宜居带(inner_radius, outer_radius, subdivisions) + self.torus_zone = 0.95, 1.67, 64 def ignore_gravity_with(self, body): """ diff --git a/sim_scenes/solar_system/solar_system_habitable_zone.py b/sim_scenes/solar_system/solar_system_habitable_zone.py index 3773607..6034c39 100644 --- a/sim_scenes/solar_system/solar_system_habitable_zone.py +++ b/sim_scenes/solar_system/solar_system_habitable_zone.py @@ -21,9 +21,9 @@ if __name__ == '__main__': # 目前认为 太阳系 的宜居带范围是从距离太阳0.95个天文单位 (约1.42亿千米)到 2.4个天文单位(约3.59亿千米)的范围为宜居带, # 其宽度约为2.17亿千米, 按照这个标准,太阳系的宜居带中只有三个大型天体,分别是地球、 月球 以及火星(1.52天文单位)。 sun = Sun(name="太阳", size_scale=0.5e2) # 太阳放大 50 倍,距离保持不变 - earth = Earth(name="地球", size_scale=1.5e3) # 地球放大 1500 倍,距离保持不变 - earth_moon_d = 20000000 # 因为地球放大 1500 倍,为了较好的效果,地月距离要比实际大才行 - moon = Moon(name="月球", size_scale=1.5e3, + earth = Earth(name="地球", size_scale=1.2e3) # 地球放大 1200 倍,距离保持不变 + earth_moon_d = 13000000 # 因为地球放大 1200 倍,已经占据了月球的轨道,为了较好的效果,地月距离要比实际大才行 + moon = Moon(name="月球", size_scale=1.3e3, init_position=[earth_moon_d, 0, AU], init_velocity=[0, 0, 0], ignore_mass=True, @@ -31,12 +31,12 @@ if __name__ == '__main__': ) bodies = [ sun, - Venus(name="金星", size_scale=1.5e3), # 金星放大 1500 倍,距离保持不变 + Venus(name="金星", size_scale=1.2e3), # 金星放大 1200 倍,距离保持不变 earth, moon, - Mars(name="火星", size_scale=2e3), # 火星放大 2000 倍,距离保持不变 + Mars(name="火星", size_scale=1.2e3), # 火星放大 1200 倍,距离保持不变 Asteroids(name="小行星群", size_scale=3.2e2, parent=sun), # 小行星群模拟(仅 ursina 模拟器支持) - HabitableZone(name="宜居带", size_scale=0.9e2, + HabitableZone(name="宜居带", size_scale=1e2, parent=sun), # 宜居带模拟(仅 ursina 模拟器支持) Jupiter(name="木星", size_scale=2e2), # 木星放大 200 倍,距离保持不变 ] @@ -48,14 +48,15 @@ if __name__ == '__main__': def on_timer_changed(time_data: TimeData): - # 1个月有多少天 - days_per_month = 27.323 + # 1个月有29.5天 + days_per_month = 29.5 # 1天多少角度 angle_per_day = 360 / days_per_month - # 当前的角度(度) + # 当前天数的角度(度) angle = time_data.total_days * angle_per_day - # 当前的角度(弧度) + # 当前天数的角度(弧度) angle = angle * np.pi / 180 + # 计算月亮的坐标(这里没有用到万有引力) px = earth_moon_d * np.cos(angle) pz = earth_moon_d * np.sin(angle) moon.position = [earth.position[0] + px, 0, earth.position[2] + pz] -- GitLab