diff --git a/bodies/earth.py b/bodies/earth.py index 31226494a9eca7ab504f1f258f3d3b0b45daf0d8..61cf0fe729c7a0cd0ee3c8aff4d11c770a40ac3b 100644 --- a/bodies/earth.py +++ b/bodies/earth.py @@ -27,7 +27,7 @@ class Earth(Body): init_position=[1.12 * AU, 0, 0], init_velocity=[0, 29.79, 0], texture="earth1.jpg", size_scale=1.0, distance_scale=1.0, - rotation_speed=15): + rotation_speed=15, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Earth(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/fixed_stars/alcyone.py b/bodies/fixed_stars/alcyone.py index ce568a4c6a2b44eaca281ee7077a40c0adcdf552..7c340109c3c8046f338d6804a5c76c5fc8acac94 100644 --- a/bodies/fixed_stars/alcyone.py +++ b/bodies/fixed_stars/alcyone.py @@ -41,7 +41,7 @@ class Alcyone(FixedStar): init_velocity=[0, 0, 0], color=(0xBB, 0xAA, 0xFF), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.45, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/aldebaran.py b/bodies/fixed_stars/aldebaran.py index 9661c8d1a2b292d6dc838cb9f80c31871b5c4ce4..f801f74ec4236cb7a25cdec388c0a2794db16110 100644 --- a/bodies/fixed_stars/aldebaran.py +++ b/bodies/fixed_stars/aldebaran.py @@ -44,7 +44,7 @@ class Aldebaran(FixedStar): init_velocity=[0, 0, 0], color=(250, 195, 47), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.35, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/antares.py b/bodies/fixed_stars/antares.py index 347fc2ad798b32fc9ac4a36ea31f7866e5ab8014..56c968e9ec7d7dbcfc2cb57f9b6892dcd59bdd24 100644 --- a/bodies/fixed_stars/antares.py +++ b/bodies/fixed_stars/antares.py @@ -50,7 +50,7 @@ class Antares(FixedStar): init_velocity=[0, 0, 0], color=(249,198,83), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.25, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/arcturus.py b/bodies/fixed_stars/arcturus.py index 6ae25102ab2acff9e973cb464b11cb493a79d35c..a20169304a618eab2783b623c3759feff14d88ce 100644 --- a/bodies/fixed_stars/arcturus.py +++ b/bodies/fixed_stars/arcturus.py @@ -46,7 +46,7 @@ class Arcturus(FixedStar): init_velocity=[0, 0, 0], color=(254,218,185), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.4, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/bellatrix.py b/bodies/fixed_stars/bellatrix.py index 199d36ddea54098d11a911a5c4627e35d556aa2d..0ec59ce38b31787f0402ca47fdb932301afc2f5f 100644 --- a/bodies/fixed_stars/bellatrix.py +++ b/bodies/fixed_stars/bellatrix.py @@ -51,7 +51,7 @@ class Bellatrix(FixedStar): init_velocity=[0, 0, 0], color=(122, 187, 255), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.5, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/betelgeuse.py b/bodies/fixed_stars/betelgeuse.py index 55ef65f3319176d6abab72d86adc03e06d138353..19f87e941cc10639d1ff9aed60cc1266b6ed634f 100644 --- a/bodies/fixed_stars/betelgeuse.py +++ b/bodies/fixed_stars/betelgeuse.py @@ -42,7 +42,7 @@ class Betelgeuse(FixedStar): init_velocity=[0, 0, 0], color=(254,162,1), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.24, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/carinae_v382.py b/bodies/fixed_stars/carinae_v382.py index fd8fab2e1530a7947aa0110209ebd140ff265e09..eca5226771be1b7926c8cde49e26413e5451b059 100644 --- a/bodies/fixed_stars/carinae_v382.py +++ b/bodies/fixed_stars/carinae_v382.py @@ -35,7 +35,7 @@ class CarinaeV382(FixedStar): init_velocity=[0, 0, 0], color=(255, 244, 89), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.26, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/eta_carinae.py b/bodies/fixed_stars/eta_carinae.py index 251a76c5540676d6f4c96cefd49785f0c536d811..88ac73a3fc6c9870f74920a1265a74289a77f0f7 100644 --- a/bodies/fixed_stars/eta_carinae.py +++ b/bodies/fixed_stars/eta_carinae.py @@ -37,7 +37,7 @@ class EtaCarinae(FixedStar): init_velocity=[0, 0, 0], color=(111,140,255), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.28, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/fixed_star.py b/bodies/fixed_stars/fixed_star.py index a503f6e0005fda0509e14ae94049d6f648c4d809..89b4646737cc3fad419a3eb24cae6508c52985f9 100644 --- a/bodies/fixed_stars/fixed_star.py +++ b/bodies/fixed_stars/fixed_star.py @@ -49,7 +49,7 @@ class FixedStar(Body): } super().__init__(**params) self.light_on = True - self.glows = 10 + self.glows = (12, 1.005, 0.08) def gen_texture(self, texture, texture_bright, texture_contrast): if texture is None: diff --git a/bodies/fixed_stars/rigel.py b/bodies/fixed_stars/rigel.py index d26361f330509857e01ebced1ad8bacbbb6b14d6..848411763a304114b16dc1b9b0bfa75f00875ff8 100644 --- a/bodies/fixed_stars/rigel.py +++ b/bodies/fixed_stars/rigel.py @@ -41,7 +41,7 @@ class Rigel(FixedStar): init_velocity=[0, 0, 0], color=(141,213,227), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.33, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/sirius.py b/bodies/fixed_stars/sirius.py index 396afbc4a1b7861f7b4c1275019dc588d1a596bb..2338e2cee1a3848a8e6c90f4508370cb3d40808b 100644 --- a/bodies/fixed_stars/sirius.py +++ b/bodies/fixed_stars/sirius.py @@ -54,7 +54,7 @@ class Sirius(FixedStar): init_velocity=[0, 0, 0], color=(0xFF, 0xFF, 0xFF), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.55, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/stephenson_2_18.py b/bodies/fixed_stars/stephenson_2_18.py index c17fd6bddc95eb90d372993c29b8c0f7cdbd7f0f..4e387e107975ab029c1856c536ea20026ff20e6a 100644 --- a/bodies/fixed_stars/stephenson_2_18.py +++ b/bodies/fixed_stars/stephenson_2_18.py @@ -50,7 +50,7 @@ class Stephenson_2_18(FixedStar): init_velocity=[0, 0, 0], color=(198, 29, 3), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.2, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/uy_scuti.py b/bodies/fixed_stars/uy_scuti.py index bf6ff0702a661310fd4212d5a5efa009a94ff93c..30d1f971fee023957d46c55b570e01392cd2507c 100644 --- a/bodies/fixed_stars/uy_scuti.py +++ b/bodies/fixed_stars/uy_scuti.py @@ -36,7 +36,7 @@ class UYScuti(FixedStar): init_velocity=[0, 0, 0], color=(255,116,0), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.22, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/vy_canis_majoris.py b/bodies/fixed_stars/vy_canis_majoris.py index 486287e1e3febf912228a04fbbadc7a3afe8653a..d986bd9b4ef441c5a2dd13fac0a4d649ee3ef5dc 100644 --- a/bodies/fixed_stars/vy_canis_majoris.py +++ b/bodies/fixed_stars/vy_canis_majoris.py @@ -50,7 +50,7 @@ class VYCanisMajoris(FixedStar): init_velocity=[0, 0, 0], color=(234,90,65), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.23, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/fixed_stars/y_canum_venaticorum.py b/bodies/fixed_stars/y_canum_venaticorum.py index 89827931e2c9569e77cd3c09bf6167794f0e5110..d053c2a733975b1bdfe650cb58d4580e24ea698f 100644 --- a/bodies/fixed_stars/y_canum_venaticorum.py +++ b/bodies/fixed_stars/y_canum_venaticorum.py @@ -31,7 +31,7 @@ class YCanumVenaticorum(FixedStar): init_velocity=[0, 0, 0], color=(255,55,18), texture="fixed_star.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.1, ignore_mass=False): + rotation_speed=0.3, ignore_mass=False): params = { "name": name, "mass": mass, diff --git a/bodies/jupiter.py b/bodies/jupiter.py index 4d3a9ed9b12ab7548f6b0886a3b9cab6cd3815f4..62836050787ed06fbd5ae88785124e33c1867b8a 100644 --- a/bodies/jupiter.py +++ b/bodies/jupiter.py @@ -27,7 +27,7 @@ class Jupiter(Body): init_position=[5.2 * AU, 0, 0], init_velocity=[0, 13.06, 0], texture="jupiter1.jpg", size_scale=1.0, distance_scale=1.0, - rotation_speed=36.2537): + rotation_speed=36.2537, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Jupiter(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/mars.py b/bodies/mars.py index 49bb1d9844dc3a67f09020a47537b9edac30ff6a..d8b951116d6f7e361f6079f54dbc2a8122d61381 100644 --- a/bodies/mars.py +++ b/bodies/mars.py @@ -26,7 +26,7 @@ class Mars(Body): init_position=[1.5 * AU, 0, 0], init_velocity=[0, 24.13, 0], texture="mars.jpg", size_scale=1.0, distance_scale=1.0, - rotation_speed=14.6223): + rotation_speed=14.6223, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -37,7 +37,9 @@ class Mars(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/mercury.py b/bodies/mercury.py index 85fada3bfd3a4bca293739841321921b940cd041..fd841d8e85e605efeb2ab8ed850f2ca06f1633c3 100644 --- a/bodies/mercury.py +++ b/bodies/mercury.py @@ -27,7 +27,7 @@ class Mercury(Body): init_position=[0.4 * AU, 0, 0], init_velocity=[0, 47.87, 0], texture="mercury.jpg", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.2558): + rotation_speed=0.2558, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Mercury(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/moon.py b/bodies/moon.py index 7b18c276d05641aaa1cfb500f1a2f4860b079338..a572ab1c1ce5304def5462e77be5ec0787a67acf 100644 --- a/bodies/moon.py +++ b/bodies/moon.py @@ -26,7 +26,7 @@ class Moon(Body): init_position=[363104 + 1.12 * AU, 0, 0], init_velocity=[0, 29.79 + 1.023, 0], texture="moon.jpg", size_scale=1.0, distance_scale=1.0, - rotation_speed=0.5487): + rotation_speed=0.5487, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -37,7 +37,9 @@ class Moon(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/neptune.py b/bodies/neptune.py index 35051b7842dd6b5987fc711eb819b637c3d7d834..5dfceb6c3123ea1f5b421bdcc8ab03d0f4040ba0 100644 --- a/bodies/neptune.py +++ b/bodies/neptune.py @@ -27,7 +27,7 @@ class Neptune(Body): init_position=[30 * AU, 0, 0], init_velocity=[0, 5.43, 0], texture="neptune.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=22.3463): + rotation_speed=22.3463, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Neptune(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/pluto.py b/bodies/pluto.py index e96be64db64f61782fef860b33d7c6f1535aa245..20f5fcafb08b78b713d4a75ce0e87638edacc197 100644 --- a/bodies/pluto.py +++ b/bodies/pluto.py @@ -27,7 +27,7 @@ class Pluto(Body): init_position=[40 * AU, 0, 0], init_velocity=[0, 4.7, 0], texture="pluto.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=-2.3474): + rotation_speed=-2.3474, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Pluto(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/saturn.py b/bodies/saturn.py index 283113d37da3378a4f40bdcb36d6f77f30f17dee..e82afeba36e6109c1f4f3663d601bb028dfd44f4 100644 --- a/bodies/saturn.py +++ b/bodies/saturn.py @@ -27,7 +27,7 @@ class Saturn(Body): init_position=[10 * AU, 0, 0], init_velocity=[0, 9.64, 0], texture="saturn.jpg", size_scale=1.0, distance_scale=1.0, - rotation_speed=33.7711): + rotation_speed=33.7711, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Saturn(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/uranus.py b/bodies/uranus.py index c37dc6f775bf6b75f6b1c1aeaf335d3a9fa2832b..ea6a4933f11d7206e1d6322a850d76a785c7b565 100644 --- a/bodies/uranus.py +++ b/bodies/uranus.py @@ -27,7 +27,7 @@ class Uranus(Body): init_position=[19 * AU, 0, 0], init_velocity=[0, 6.81, 0], texture="uranus.png", size_scale=1.0, distance_scale=1.0, - rotation_speed=-20.8816): + rotation_speed=-20.8816, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Uranus(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/bodies/venus.py b/bodies/venus.py index 60ae19866e49feda65591eb6139bf10b79c59460..ce681a2edece118a7d7c9250f004267e316f8f60 100644 --- a/bodies/venus.py +++ b/bodies/venus.py @@ -27,7 +27,7 @@ class Venus(Body): init_position=[0.72 * AU, 0, 0], init_velocity=[0, 35, 0], texture="venus.jpg", size_scale=1.0, distance_scale=1.0, - rotation_speed=-0.0617): + rotation_speed=-0.0617, ignore_mass=False, trail_color=None): params = { "name": name, "mass": mass, @@ -38,7 +38,9 @@ class Venus(Body): "texture": texture, "size_scale": size_scale, "distance_scale": distance_scale, - "rotation_speed": rotation_speed + "rotation_speed": rotation_speed, + "ignore_mass": ignore_mass, + "trail_color": trail_color } super().__init__(**params) diff --git a/scenes/fixed_stars.py b/scenes/fixed_stars.py index 9e0edf31f15a9d92db474cac2520fd73a1dc93d7..c901d7d2c82730407d59128dc19a9b35ca88b7ef 100644 --- a/scenes/fixed_stars.py +++ b/scenes/fixed_stars.py @@ -18,10 +18,10 @@ if __name__ == '__main__': """ # 构建两个天体对象(太阳、地球) D = 5e5 - SIZE_SCALE = 0.02 + SIZE_SCALE = 0.5 bodies = [ - Earth(size_scale=1, init_velocity=[0, 29.79, 0], distance_scale=0.0006), - Sun(size_scale=SIZE_SCALE), # 太阳 + Earth(size_scale=SIZE_SCALE, ignore_mass=True), + Sun(size_scale=SIZE_SCALE, ignore_mass=True), # 太阳 Sirius(size_scale=SIZE_SCALE, ignore_mass=True), # 天狼星A 质量倍数 2.06 半径倍数 1.71 Bellatrix(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿五 质量倍数 8.6 半径倍数 5.75 Alcyone(size_scale=SIZE_SCALE, ignore_mass=True), # 昴宿六 质量倍数 7 半径倍数 10 @@ -31,9 +31,6 @@ if __name__ == '__main__': YCanumVenaticorum(size_scale=SIZE_SCALE, ignore_mass=True), # 猎犬座Y 质量倍数 3.0 半径倍数 215 EtaCarinae(size_scale=SIZE_SCALE, ignore_mass=True), # 海山二 质量倍数 100.0 半径倍数 278 CarinaeV382(size_scale=SIZE_SCALE, ignore_mass=True), # 船底座V382 质量倍数 20.0 半径倍数 350 - - - Antares(size_scale=SIZE_SCALE, ignore_mass=True), # 心宿二 质量倍数 12 半径倍数 770 Betelgeuse(size_scale=SIZE_SCALE, ignore_mass=True), # 参宿四 质量倍数 11.6 半径倍数 887 VYCanisMajoris(size_scale=SIZE_SCALE, ignore_mass=True), # 大犬座VY 质量倍数 25 半径倍数 1419.75 @@ -43,14 +40,18 @@ if __name__ == '__main__': distance_sum = 0 for idx, body in enumerate(bodies): body.rotation_speed /= 10 - if idx > 1: + if body.is_fixed_star: body.light_on = False # 关闭灯光效果,只有太阳对地球有灯光效果 - d = pow((body.diameter + bodies[idx - 1].diameter) * SIZE_SCALE, 0.75) * 80 - # d = (body.diameter + bodies[idx - 1].diameter) * SIZE_SCALE * 1.1 + D - body.init_position = [(distance_sum + d) / 2, (distance_sum + d), 0] - distance_sum += d + if idx == 0: + d = 0 + else: + d = pow((body.raduis + bodies[idx - 1].raduis) * SIZE_SCALE, 1.0) * 1.1 + # d = (body.diameter + bodies[idx - 1].diameter) * SIZE_SCALE * 1.1 + D + body.init_velocity = [0, 0, 0] + body.init_position = [body.raduis * SIZE_SCALE, (distance_sum + d), AU] + distance_sum += d # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- - ursina_run(bodies, SECONDS_PER_MONTH, position=(0, 200000, -AU / 200), show_trail=True) + ursina_run(bodies, SECONDS_PER_WEEK, position=(0, AU, -AU / 500), show_trail=True)