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

太阳系三体模拟器

上级 09817f55
...@@ -28,7 +28,7 @@ if __name__ == '__main__': ...@@ -28,7 +28,7 @@ if __name__ == '__main__':
Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍 Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍
Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍 Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍
Earth(size_scale=4e3, distance_scale=1.3), # 地球放大 4000 倍,距离放大 1.3 倍 Earth(size_scale=4e3, distance_scale=1.3), # 地球放大 4000 倍,距离放大 1.3 倍
Asteroids(size_scale=3e2, parent=sun), # 小行星模拟 Asteroids(size_scale=3e2, parent=sun), # 小行星模拟(仅 ursina 模拟器支持)
Mars(size_scale=4e3, distance_scale=1.3), # 火星放大 4000 倍,距离放大 1.3 倍 Mars(size_scale=4e3, distance_scale=1.3), # 火星放大 4000 倍,距离放大 1.3 倍
Jupiter(size_scale=0.68e3, distance_scale=0.65), # 木星放大 680 倍,距离缩小到真实距离的 0.65 Jupiter(size_scale=0.68e3, distance_scale=0.65), # 木星放大 680 倍,距离缩小到真实距离的 0.65
Saturn(size_scale=0.68e3, distance_scale=0.52), # 土星放大 680 倍,距离缩小到真实距离的 0.52 Saturn(size_scale=0.68e3, distance_scale=0.52), # 土星放大 680 倍,距离缩小到真实距离的 0.52
......
...@@ -94,6 +94,10 @@ class MplSimulator(Simulator): ...@@ -94,6 +94,10 @@ class MplSimulator(Simulator):
update_ax(ax, styles) update_ax(ax, styles)
for idx, body in enumerate(bodies): for idx, body in enumerate(bodies):
if hasattr(body, "torus_stars"):
# 暂不支持环状小行星群
continue
if body.is_fixed_star: if body.is_fixed_star:
color = 'red' color = 'red'
else: else:
...@@ -116,7 +120,7 @@ class MplSimulator(Simulator): ...@@ -116,7 +120,7 @@ class MplSimulator(Simulator):
ax.plot3D(_his_pos[0], _his_pos[1], _his_pos[2], color=color, alpha=0.5) ax.plot3D(_his_pos[0], _his_pos[1], _his_pos[2], color=color, alpha=0.5)
z_range = ax.get_zlim()[1] - ax.get_zlim()[0] z_range = ax.get_zlim()[1] - ax.get_zlim()[0]
ax.text(pos[0], pos[1], pos[2] + size*(z_range/5000), s=body.name, color=color, fontsize=12) ax.text(pos[0], pos[1], pos[2] + size * (z_range / 5000), s=body.name, color=color, fontsize=12)
if pause > 0: if pause > 0:
plt.pause(pause) plt.pause(pause)
......
...@@ -85,6 +85,10 @@ class MayaviView(BodyView): ...@@ -85,6 +85,10 @@ class MayaviView(BodyView):
天体显示的操作,比如:构建天体视图对象 天体显示的操作,比如:构建天体视图对象
:return: :return:
""" """
if hasattr(self.body, "torus_stars"):
# 暂不支持环状小行星群
return
if not hasattr(self, "sphere") or self.sphere is None: if not hasattr(self, "sphere") or self.sphere is None:
scale_factor = self.body.size_scale * self.body.diameter scale_factor = self.body.size_scale * self.body.diameter
sphere = mlab.points3d(self.body.position[0], self.body.position[1], self.body.position[2], sphere = mlab.points3d(self.body.position[0], self.body.position[1], self.body.position[2],
...@@ -130,7 +134,7 @@ class MayaviView(BodyView): ...@@ -130,7 +134,7 @@ class MayaviView(BodyView):
:param image_file: :param image_file:
:return: :return:
""" """
outfile = image_file.replace('.jpg', '_flipped.jpg') outfile = image_file.replace('.jpg', '_flipped.jpg').replace('.png', '_flipped.jpg')
if os.path.exists(outfile): if os.path.exists(outfile):
image_file = outfile image_file = outfile
else: else:
......
...@@ -23,7 +23,9 @@ class MplView(BodyView): ...@@ -23,7 +23,9 @@ class MplView(BodyView):
pass pass
def appear(self): def appear(self):
pass if hasattr(self.body, "torus_stars"):
# 暂不支持环状小行星群
return
def disappear(self): def disappear(self):
pass pass
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册