提交 9ef242fd 编写于 作者: 我可以学Python吗's avatar 我可以学Python吗

太阳系三体模拟器

上级 88b4bd38
......@@ -307,7 +307,7 @@ class Body(metaclass=ABCMeta):
def __repr__(self):
return '<%s(%s)> m=%.3e(kg), r|d=%.3e|%.3e(km), v=%.3e(km³), d=%.3e(kg/m³), p=[%.3e,%.3e,%.3e](km), v=%s(km/s)' % \
(self.name,self.__class__.__name__, self.mass, self.raduis, self.diameter, self.volume, self.density,
(self.name, self.__class__.__name__, self.mass, self.raduis, self.diameter, self.volume, self.density,
self.position[0], self.position[1], self.position[2], self.velocity)
def ignore_gravity(self, body):
......@@ -371,12 +371,15 @@ class Body(metaclass=ABCMeta):
except Exception as e:
err_msg = f"{json_file} 格式错误:" + str(e)
raise Exception(err_msg)
is_fixed_star = False
if "is_fixed_star" in body_data:
if body_data["is_fixed_star"]:
body_data.pop("is_fixed_star")
body = FixedStar(**body_data)
else:
is_fixed_star = True
if is_fixed_star:
body_data.pop("is_fixed_star")
body = FixedStar(**body_data)
else:
body = Body(**body_data)
bodies.append(body)
if "params" in json_data:
params = json_data["params"]
......
......@@ -59,6 +59,8 @@
0,
149597870.7,
-448793612.09999996
]
],
"show_trail": true,
"show_name": false
}
}
\ No newline at end of file
......@@ -59,6 +59,8 @@
0,
149597870.7,
-448793612.09999996
]
],
"show_trail": true,
"show_name": false
}
}
\ No newline at end of file
......@@ -102,6 +102,8 @@
0,
149597870.7,
-1495978707.0
]
],
"show_trail": true,
"show_name": false
}
}
\ No newline at end of file
......@@ -79,6 +79,8 @@
0,
149597870.7,
-1495978707.0
]
],
"show_trail": true,
"show_name": false
}
}
\ No newline at end of file
......@@ -79,6 +79,8 @@
0,
149597870.7,
-1495978707.0
]
],
"show_trail": true,
"show_name": false
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ if __name__ == '__main__':
dt = params["dt"] if "dt" in params else SECONDS_PER_YEAR
position = params["position"] if "position" in params else (0, 0, 0)
show_trail = params["show_trail"] if "show_trail" in params else True
show_trail = params["show_trail"] if "show_trail" in params else False
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册