提交 c9128166 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 151048bb
......@@ -27,8 +27,6 @@ class Asteroid(Body):
"""
def __init__(self, name="小行星", mass=4.1e10,
# init_position=[1.6 * AU, 0, 0],
# init_velocity=[0, 25.37, 0],
init_position=[0, 0, 1.6 * AU],
init_velocity=[-25.37, 0, 0],
texture="", size_scale=1.0, distance_scale=1.0):
......
......@@ -23,8 +23,6 @@ class Earth(Body):
 平均密度: 5507.85 kg/m³
"""
def __init__(self, name="地球", mass=5.97237e24,rotate_angle=0,
# init_position=[1.12 * AU, 0, 0],
# init_velocity=[0, 29.79, 0],
init_position=[0, 0, 1.12 * AU],
init_velocity=[-29.79, 0, 0],
texture="earth1.jpg", size_scale=1.0, distance_scale=1.0,
......
......@@ -23,8 +23,6 @@ class Jupiter(Body):
 平均密度: 1.326 g/cm³ -> -> 1.326✕10³ kg/m³
"""
def __init__(self, name="木星", mass=1.8982e27,
# init_position=[5.2 * AU, 0, 0],
# init_velocity=[0, 13.06, 0],
init_position=[0, 0, 5.2 * AU],
init_velocity=[-13.06, 0, 0],
texture="jupiter1.jpg", size_scale=1.0, distance_scale=1.0,
......
......@@ -23,8 +23,6 @@ class Mars(Body):
 平均密度: 3.9335 g/cm³ -> 3.9335✕10³ kg/m³
"""
def __init__(self, name="火星", mass=6.4171e23,
# init_position=[1.5 * AU, 0, 0],
# init_velocity=[0, 24.13, 0],
init_position=[0, 0, 1.5 * AU],
init_velocity=[-24.13, 0, 0],
texture="mars.jpg", size_scale=1.0, distance_scale=1.0,
......
......@@ -24,8 +24,6 @@ class Mercury(Body):
"""
def __init__(self, name="水星", mass=3.3011e23,
# init_position=[0.4 * AU, 0, 0],
# init_velocity=[0, 47.87, 0],
init_position=[0, 0, 0.4 * AU],
init_velocity=[-47.87, 0, 0],
texture="mercury.jpg", size_scale=1.0, distance_scale=1.0,
......
......@@ -23,8 +23,6 @@ class Moon(Body):
"""
def __init__(self, name="月球", mass=7.342e22,
# init_position=[363104 + 1.12 * AU, 0, 0],
# init_velocity=[0, 29.79 + 1.023, 0],
init_position=[0, 0, 363104 + 1.12 * AU],
init_velocity=[-(29.79 + 1.023), 0, 0],
texture="moon.jpg", size_scale=1.0, distance_scale=1.0,
......
......@@ -24,8 +24,6 @@ class Neptune(Body):
"""
def __init__(self, name="海王星", mass=1.0241e26,
# init_position=[30 * AU, 0, 0],
# init_velocity=[0, 5.43, 0],
init_position=[0, 0, 30 * AU],
init_velocity=[-5.43, 0, 0],
texture="neptune.png", size_scale=1.0, distance_scale=1.0,
......
......@@ -24,8 +24,6 @@ class Pluto(Body):
"""
def __init__(self, name="冥王星", mass=1.303e22,
# init_position=[40 * AU, 0, 0],
# init_velocity=[0, 4.7, 0],
init_position=[0, 0, 40 * AU],
init_velocity=[-4.7, 0, 0],
texture="pluto.png", size_scale=1.0, distance_scale=1.0,
......
......@@ -24,8 +24,6 @@ class Saturn(Body):
"""
def __init__(self, name="土星", mass=5.6834e26,
# init_position=[10 * AU, 0, 0],
# init_velocity=[0, 9.64, 0],
init_position=[0, 0, 10 * AU],
init_velocity=[-9.64, 0, 0],
texture="saturn.jpg", size_scale=1.0, distance_scale=1.0,
......
......@@ -24,8 +24,6 @@ class Uranus(Body):
"""
def __init__(self, name="天王星", mass=8.681e25,
# init_position=[19 * AU, 0, 0],
# init_velocity=[0, 6.81, 0],
init_position=[0, 0, 19 * AU],
init_velocity=[-6.81, 0, 0],
texture="uranus.png", size_scale=1.0, distance_scale=1.0,
......
......@@ -24,8 +24,6 @@ class Venus(Body):
"""
def __init__(self, name="金星", mass=4.8675e24,
# init_position=[0.72 * AU, 0, 0],
# init_velocity=[0, 35, 0],
init_position=[0, 0, 0.72 * AU],
init_velocity=[-35, 0, 0],
texture="venus.jpg", size_scale=1.0, distance_scale=1.0,
......
......@@ -48,7 +48,6 @@ if __name__ == '__main__':
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]
body.init_position = [-(distance_sum + d), AU, body.raduis * SIZE_SCALE]
distance_sum += d
......
......@@ -26,8 +26,7 @@ def show_text_bodies():
params={"camera_pos": camera_pos})
# 放一个恒星作为背景
bg = FixedStar(name="bg", texture="fixed_star.png", mass=2e32, color=(0xff, 0xf8, 0xd4),
# init_position=[6000 * D, 450 * D, 100 * D], # [ 远+近- , 左+右- , 上+下-]
init_position=[-450 * D, 100 * D, 6000 * D], # [ 远+近- , 左+右- , 上+下-]
init_position=[-450 * D, 100 * D, 6000 * D], # [ 左-右+, 上+下-, 远+近- ]
ignore_mass=True)
bodies.append(bg)
......
......@@ -25,8 +25,7 @@ def show_eye_of_god():
params={"camera_pos": camera_pos})
# 放一个恒星作为背景
bg = FixedStar(name="bg", texture="fixed_star.png", mass=2e32, color=(0xff, 0xf8, 0xd4),
# init_position=[6000 * D, 400 * D, 100 * D], # [ 远+近- , 左+右- , 上+下-]
init_position=[-400 * D, 100 * D, 6000 * D], # [ 远+近- , 左+右- , 上+下-]
init_position=[-400 * D, 100 * D, 6000 * D], # [ 左-右+, 上+下-, 远+近- ]
ignore_mass=True)
bodies.append(bg)
......
......@@ -18,11 +18,9 @@ if __name__ == '__main__':
bodies = [
Sun(size_scale=2e1), # 太阳放大 20 倍
Earth(size_scale=1e3, # 地球放大 1000 倍
# init_position=[0, -3 * AU, 0], # 地球距离太阳 3 个天文单位
init_position=[3 * AU, 0, 0], # 地球距离太阳 3 个天文单位
# TODO: 尝试调整朝向太阳的速度,取值 33、38、50 或者其他
# init_velocity=[0, 33, -1],
# init_velocity=[0, 38, -1], # 朝向太阳的速度为 38km/s,-1 km/s 是为了防止地球正面对着太阳冲去
init_velocity=[-38, -1, 0], # 朝向太阳的速度为 38km/s,-1 km/s 是为了防止地球正面对着太阳冲去
# init_velocity=[0, 50, -1],
),
......
......@@ -21,7 +21,6 @@ if __name__ == '__main__':
Earth(size_scale=3e2, # 地球放大 300 倍
init_position=[0, 0, 0], #
# init_velocity=[0, 33, -1],
# init_velocity=[-1, 10, 0], # 朝向木星的速度为 38km/s,-1 km/s 是为了防止地球正面对着木星冲去
init_velocity=[-10, 0, -1], # 朝向木星的速度为 38km/s,-1 km/s 是为了防止地球正面对着木星冲去
# init_velocity=[0, 50, -1],
),
......
......@@ -14,10 +14,6 @@ from bodies.body import AU
if __name__ == '__main__':
"""
地球、月球
init_position=[x, y, z],
init_position=[-y, z, x],
init_velocity=[x, y, z],
init_velocity=[-y, z, x],
"""
# 地球的Y方向初始速度
EARTH_INIT_VELOCITY = 0
......
......@@ -27,20 +27,20 @@ if __name__ == '__main__':
# region 1.构建4个小行星 -------------
# asteroids = [
# Asteroid(size_scale=3e9, # 小行星放大 1000000000 倍,距离保持不变
# init_position=[1.6 * AU, 0, 0],
# init_velocity=[0, 25.37, 0],
# init_position=[0, 0, 1.6 * AU],
# init_velocity=[-25.37, 0, 0],
# distance_scale=1),
# Asteroid(size_scale=3e9, # 小行星放大 1000000000 倍,距离保持不变
# init_position=[-1.6 * AU, 0, 0],
# init_velocity=[0, -25.37, 0],
# init_position=[0, 0, -1.6 * AU],
# init_velocity=[25.37, 0, 0],
# distance_scale=1),
# Asteroid(size_scale=3e9, # 小行星放大 1000000000 倍,距离保持不变
# init_position=[0, 1.6 * AU, 0],
# init_velocity=[-25.37, 0, 0],
# init_position=[-1.6 * AU, 0, 0],
# init_velocity=[0, 0, -25.37],
# distance_scale=1),
# Asteroid(size_scale=3e9, # 小行星放大 1000000000 倍,距离保持不变
# init_position=[0, -1.6 * AU, 0],
# init_velocity=[25.37, 0, 0],
# init_position=[1.6 * AU, 0, 0],
# init_velocity=[0, 0, 25.37],
# distance_scale=1),
# ]
# endregion 1 --------------------------
......
......@@ -12,7 +12,7 @@ from sim_scenes.func import mayavi_run, ursina_run
if __name__ == '__main__':
"""
太阳、地球 Sirius(size_scale=0.2, init_position=[0, 0, 0]),
太阳、地球
"""
bodies = [
Sun(size_scale=5e1), # 太阳放大 50 倍
......
......@@ -18,7 +18,7 @@ if __name__ == '__main__':
# 地球的Y方向初始速度
EARTH_INIT_VELOCITY = 0 # 0km/s
sun = Sun(init_position=[0, 0, AU], size_scale=2e1) # 太阳放大 20 倍
# 忽略质量的引力 [x, y, z]->[-y, z, x]
# 忽略质量的引力
sun.ignore_mass = True
# 观看月相变化的过程:分别是 新月、蛾眉月、上弦月、盈凸、满月、亏凸、下弦月、残月
......
......@@ -23,11 +23,10 @@ if __name__ == '__main__':
mass = 2e30
r = 2 * AU
# p = 12 # TODO: 三体转圆形花
p = 14.88 # TODO: 三体转圈近似圆形
p = 14.95 # TODO: 三体转圈近似圆形
# p = 16 # TODO: 三体转圆形花
# p = 18 # TODO: 三体转圆形花
# p = 19 # TODO: 三体转圆形花
# [x, y, z]->[-y, z, x]
bodies = [
Sun(name="红轨太阳A", mass=mass,
init_position=[0, math.sqrt(3) * r, 0],
......@@ -44,9 +43,9 @@ if __name__ == '__main__':
init_velocity=[1 / 2 * p, math.sqrt(3) / 2 * p, 0],
trail_color=(0, 0, 255),
size_scale=5e1, texture="sun2.jpg"), # 太阳放大 100 倍
# Earth(init_position=[0, -349597870.700, 0],
# init_velocity=[15.50, 0, 0],
# size_scale=4e3, distance_scale=1), # 地球放大 4000 倍,距离保持不变
Earth(init_position=[0, 2 * r / math.sqrt(12), r * 3],
init_velocity=[0, 0, 0],
size_scale=4e3, distance_scale=1), # 地球放大 4000 倍,距离保持不变
]
# 使用 mayavi 查看的运行效果
# mayavi_run(bodies, SECONDS_PER_WEEK, view_azimuth=0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册