Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
太阳系三体模拟器
提交
bac2ca3a
太阳系三体模拟器
项目概览
Python_超人
/
太阳系三体模拟器
通知
1116
Star
131
Fork
129
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
太阳系三体模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
bac2ca3a
编写于
2月 11, 2023
作者:
M
march3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
三体运行模拟器
上级
495f030b
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
120 addition
and
130 deletion
+120
-130
bodies/asteroid.py
bodies/asteroid.py
+5
-4
bodies/body.py
bodies/body.py
+5
-5
bodies/earth.py
bodies/earth.py
+4
-4
bodies/jupiter.py
bodies/jupiter.py
+4
-4
bodies/mars.py
bodies/mars.py
+4
-4
bodies/mercury.py
bodies/mercury.py
+4
-4
bodies/moon.py
bodies/moon.py
+6
-6
bodies/neptune.py
bodies/neptune.py
+4
-4
bodies/pluto.py
bodies/pluto.py
+4
-4
bodies/saturn.py
bodies/saturn.py
+4
-4
bodies/sun.py
bodies/sun.py
+4
-4
bodies/uranus.py
bodies/uranus.py
+4
-4
bodies/venus.py
bodies/venus.py
+4
-4
common/consts.py
common/consts.py
+4
-4
common/func.py
common/func.py
+17
-28
common/system.py
common/system.py
+4
-4
scenes/demo.py
scenes/demo.py
+2
-2
scenes/func.py
scenes/func.py
+4
-4
scenes/solar_system_1.py
scenes/solar_system_1.py
+2
-2
scenes/solar_system_2.py
scenes/solar_system_2.py
+2
-2
scenes/solar_system_3.py
scenes/solar_system_3.py
+9
-9
scenes/sun_earth.py
scenes/sun_earth.py
+2
-2
scenes/sun_earth_jupiter.py
scenes/sun_earth_jupiter.py
+2
-2
scenes/three_body_01.py
scenes/three_body_01.py
+2
-2
scenes/three_body_02.py
scenes/three_body_02.py
+2
-2
simulators/mayavi_simulator.py
simulators/mayavi_simulator.py
+2
-2
simulators/mpl_simulator.py
simulators/mpl_simulator.py
+2
-2
simulators/simulator.py
simulators/simulator.py
+2
-2
simulators/views/body_view.py
simulators/views/body_view.py
+2
-2
simulators/views/mayavi_view.py
simulators/views/mayavi_view.py
+2
-2
simulators/views/mpl_view.py
simulators/views/mpl_view.py
+2
-2
未找到文件。
bodies/asteroid.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
小行星
# description :
小行星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
@@ -55,6 +55,7 @@ class Asteroid(Body):
return
True
if
__name__
==
'__main__'
:
asteroid
=
Asteroid
()
print
(
asteroid
)
bodies/body.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
天体基类
# description :
天体基类(所有星体都继承了该类)
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
abc
import
ABCMeta
,
abstractmethod
...
...
@@ -15,7 +15,7 @@ from common.consts import AU
class
Body
(
metaclass
=
ABCMeta
):
"""
天体
信息
基类
天体基类
"""
def
__init__
(
self
,
name
,
mass
,
init_position
,
init_velocity
,
...
...
bodies/earth.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
地球
# description :
地球
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/jupiter.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
木星
# description :
木星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/mars.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
火星
# description :
火星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/mercury.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
水星
# description :
水星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/moon.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
月球
# description :
月球
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
@@ -40,5 +40,5 @@ class Moon(Body):
if
__name__
==
'__main__'
:
earth
=
Earth
()
print
(
earth
)
moon
=
Moon
()
print
(
moon
)
bodies/neptune.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
海王星
# description :
海王星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/pluto.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
冥王星
# description :
冥王星(从太阳系的行星中排除)
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/saturn.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
土星
# description :
土星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/sun.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
太阳
# description :
太阳
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
...
...
bodies/uranus.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
天王星
# description :
天王星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
bodies/venus.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
金星
# description :
金星
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies.body
import
Body
,
AU
...
...
common/consts.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
常量定义
# description :
常量定义
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
...
...
common/func.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
公共库函数
# description :
公共库函数
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
PIL
import
Image
...
...
@@ -42,26 +42,15 @@ def get_dominant_colors(infile, resize=(20, 20)):
return
colors
def
circle_x_y
(
points
,
radius
=
1.6
*
AU
):
def
get_positions_velocitys
(
angles
,
velocity
=
1
,
radius
=
1
,
radius_offset
=
None
,
velocity_offset
=
None
):
"""
:param points:
:param radius:
:return:
"""
x
=
radius
*
np
.
cos
(
points
)
y
=
radius
*
np
.
sin
(
points
)
return
x
,
y
def
get_position_force
(
angles
,
force
=
1
,
radius
=
1
,
radius_offset
=
None
,
force_offset
=
None
):
"""
:param angles:
:param force:
:param radius:
:param radius_offset:
:param force_offset:
以位置 (0, 0, 0)为中心,随机获取空间上的位置和公转方向的速度集合
(比如:获取大批小行星的位置)
:param angles: 参考中心位置(0, 0, 0)的角度集合
:param velocity: 速度
:param radius: 半径(距离中心位置(0, 0, 0)的距离)
:param radius_offset:在半径的基础上,随机偏移的值
:param velocity_offset:在速度的基础上,随机偏移的值
:return:
"""
angles
=
np
.
array
(
angles
*
np
.
pi
)
...
...
@@ -69,17 +58,17 @@ def get_position_force(angles, force=1, radius=1, radius_offset=None, force_offs
if
isinstance
(
radius_offset
,
float
):
radius
=
radius
+
np
.
random
.
rand
(
len
(
angles
))
*
radius_offset
if
isinstance
(
force
_offset
,
float
):
force
=
force
+
np
.
random
.
rand
(
len
(
angles
))
*
force
_offset
if
isinstance
(
velocity
_offset
,
float
):
velocity
=
velocity
+
np
.
random
.
rand
(
len
(
angles
))
*
velocity
_offset
pxs
=
radius
*
np
.
cos
(
angles
)
pys
=
radius
*
np
.
sin
(
angles
)
fys
=
force
*
np
.
cos
(
angles
)
# math.cos(math.radians(angle)
)
fxs
=
force
*
np
.
sin
(
angles
)
# math.sin(math.radians(angle)
)
vys
=
velocity
*
np
.
cos
(
angles
)
vxs
=
velocity
*
np
.
sin
(
angles
)
# return pxs, pys, fxs, fys
return
np
.
round
(
pxs
,
2
),
np
.
round
(
pys
,
2
),
-
np
.
round
(
fxs
,
2
),
np
.
round
(
f
ys
,
2
)
return
np
.
round
(
pxs
,
2
),
np
.
round
(
pys
,
2
),
-
np
.
round
(
vxs
,
2
),
np
.
round
(
v
ys
,
2
)
def
calculate_distance
(
pos1
,
pos2
=
[
0
,
0
,
0
]):
...
...
common/system.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
天体系统
# description :
天体系统,多个天体就是一个系统
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
import
numpy
as
np
...
...
scenes/demo.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Earth
...
...
scenes/func.py
浏览文件 @
bac2ca3a
# -*- coding:utf-8 -*-
# title :
# description :
# title :
场景用功能库
# description :
场景用功能库
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
common.consts
import
SECONDS_PER_WEEK
...
...
scenes/solar_system_1.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :太阳系场景
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
...
...
scenes/solar_system_2.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :太阳系场景
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
...
...
scenes/solar_system_3.py
浏览文件 @
bac2ca3a
...
...
@@ -2,14 +2,14 @@
# title :太阳系场景
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Asteroid
from
bodies.body
import
AU
from
common.consts
import
SECONDS_PER_WEEK
from
common.func
import
get_position
_force
from
common.func
import
get_position
s_velocitys
from
scenes.func
import
mayavi_run
import
numpy
as
np
...
...
@@ -50,13 +50,13 @@ if __name__ == '__main__':
NUM_OF_ASTEROIDS
=
60
asteroids
=
[]
angles
=
np
.
linspace
(
0
,
40
*
np
.
pi
,
NUM_OF_ASTEROIDS
)
pxs
,
pys
,
fxs
,
fys
=
get_position_force
(
angles
,
radius
=
1.60
*
AU
,
force
=
23.37
,
radius_offset
=
0.1
*
AU
,
force
_offset
=
0.2
)
pxs
,
pys
,
vxs
,
vys
=
get_positions_velocitys
(
angles
,
radius
=
1.60
*
AU
,
velocity
=
23.37
,
radius_offset
=
0.1
*
AU
,
velocity
_offset
=
0.2
)
for
i
,
px
in
enumerate
(
pxs
):
py
,
fx
,
fy
=
pys
[
i
],
fxs
[
i
],
f
ys
[
i
]
py
,
fx
,
fy
=
pys
[
i
],
vxs
[
i
],
v
ys
[
i
]
asteroids
.
append
(
Asteroid
(
size_scale
=
1e9
,
# 小行星放大 1000000000 倍,距离放大 1.4 倍
init_position
=
[
px
,
py
,
0
],
init_velocity
=
[
fx
,
fy
,
0
],
...
...
scenes/sun_earth.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Earth
...
...
scenes/sun_earth_jupiter.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Earth
,
Jupiter
...
...
scenes/three_body_01.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :太阳系场景
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
mayavi
import
mlab
...
...
scenes/three_body_02.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :太阳系场景
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
mayavi
import
mlab
...
...
simulators/mayavi_simulator.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
mayavi
import
mlab
...
...
simulators/mpl_simulator.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
import
matplotlib.pyplot
as
plt
...
...
simulators/simulator.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
abc
import
ABCMeta
,
abstractmethod
...
...
simulators/views/body_view.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
abc
import
ABCMeta
,
abstractmethod
...
...
simulators/views/mayavi_view.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
mayavi
import
mlab
...
...
simulators/views/mpl_view.py
浏览文件 @
bac2ca3a
...
...
@@ -2,8 +2,8 @@
# title :
# description :
# author :Python超人
# date :2023-0
1-22
#
notes :
# date :2023-0
2-11
#
link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
import
os
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录