Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
151048bb
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
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看板
提交
151048bb
编写于
4月 02, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更改了坐标[x, y, z]->[-y, z, x],备份,后面将删除注释和清理代码
上级
11659848
变更
47
隐藏空白更改
内联
并排
Showing
47 changed file
with
353 addition
and
248 deletion
+353
-248
bodies/asteroid.py
bodies/asteroid.py
+8
-2
bodies/body.py
bodies/body.py
+3
-0
bodies/earth.py
bodies/earth.py
+4
-3
bodies/jupiter.py
bodies/jupiter.py
+4
-3
bodies/mars.py
bodies/mars.py
+4
-2
bodies/mercury.py
bodies/mercury.py
+4
-2
bodies/moon.py
bodies/moon.py
+4
-2
bodies/neptune.py
bodies/neptune.py
+4
-2
bodies/pluto.py
bodies/pluto.py
+4
-2
bodies/saturn.py
bodies/saturn.py
+4
-2
bodies/uranus.py
bodies/uranus.py
+4
-2
bodies/venus.py
bodies/venus.py
+4
-2
common/func.py
common/func.py
+4
-4
data/gravity_slingshot.json
data/gravity_slingshot.json
+6
-6
data/sun_earth.json
data/sun_earth.json
+5
-5
data/sun_earth_moon.json
data/sun_earth_moon.json
+29
-12
data/tri_bodies_perfect_01.json
data/tri_bodies_perfect_01.json
+49
-35
data/tri_bodies_perfect_02.json
data/tri_bodies_perfect_02.json
+34
-28
data/tri_bodies_perfect_03.json
data/tri_bodies_perfect_03.json
+34
-28
data/tri_bodies_perfect_04.json
data/tri_bodies_perfect_04.json
+13
-13
data/tri_bodies_perfect_05.json
data/tri_bodies_perfect_05.json
+13
-13
sim_scenes/fiction/fixed_stars.py
sim_scenes/fiction/fixed_stars.py
+2
-1
sim_scenes/fiction/sun_dysen_sphere.py
sim_scenes/fiction/sun_dysen_sphere.py
+2
-2
sim_scenes/interest/text_bodies.py
sim_scenes/interest/text_bodies.py
+3
-1
sim_scenes/interest/the_eye_of_god.py
sim_scenes/interest/the_eye_of_god.py
+2
-1
sim_scenes/interest/utils/body_utils.py
sim_scenes/interest/utils/body_utils.py
+6
-2
sim_scenes/science/gravity_slingshot_1.py
sim_scenes/science/gravity_slingshot_1.py
+4
-2
sim_scenes/science/gravity_slingshot_2.py
sim_scenes/science/gravity_slingshot_2.py
+4
-3
sim_scenes/solar_system/earth_at_night.py
sim_scenes/solar_system/earth_at_night.py
+3
-2
sim_scenes/solar_system/earth_moon.py
sim_scenes/solar_system/earth_moon.py
+8
-4
sim_scenes/solar_system/earth_moon6.py
sim_scenes/solar_system/earth_moon6.py
+1
-1
sim_scenes/solar_system/hd_earth.py
sim_scenes/solar_system/hd_earth.py
+3
-3
sim_scenes/solar_system/hd_mercury.py
sim_scenes/solar_system/hd_mercury.py
+3
-3
sim_scenes/solar_system/hd_pluto.py
sim_scenes/solar_system/hd_pluto.py
+4
-4
sim_scenes/solar_system/hd_venus.py
sim_scenes/solar_system/hd_venus.py
+3
-3
sim_scenes/solar_system/solar_system_1.py
sim_scenes/solar_system/solar_system_1.py
+1
-1
sim_scenes/solar_system/solar_system_3.py
sim_scenes/solar_system/solar_system_3.py
+4
-4
sim_scenes/solar_system/sun_earth_moon.py
sim_scenes/solar_system/sun_earth_moon.py
+7
-7
sim_scenes/tri_bodies/tri_bodies_perfect.py
sim_scenes/tri_bodies/tri_bodies_perfect.py
+1
-0
sim_scenes/tri_bodies/two_bodies_01.py
sim_scenes/tri_bodies/two_bodies_01.py
+3
-3
sim_scenes/ursina_json_sim.py
sim_scenes/ursina_json_sim.py
+1
-1
simulators/ursina/entities/body_trail.py
simulators/ursina/entities/body_trail.py
+9
-0
simulators/ursina/entities/entity_utils.py
simulators/ursina/entities/entity_utils.py
+13
-13
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+20
-13
simulators/ursina/ursina_mesh.py
simulators/ursina/ursina_mesh.py
+7
-5
simulators/views/ursina_view.py
simulators/views/ursina_view.py
+1
-1
sounds/interstellar.mp3
sounds/interstellar.mp3
+0
-0
未找到文件。
bodies/asteroid.py
浏览文件 @
151048bb
...
...
@@ -27,8 +27,10 @@ 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=[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
):
params
=
{
"name"
:
name
,
...
...
@@ -43,6 +45,10 @@ class Asteroid(Body):
}
super
().
__init__
(
**
params
)
@
property
def
show_trail
(
self
):
return
False
def
ignore_gravity
(
self
,
body
):
"""
是否忽略引力
...
...
bodies/body.py
浏览文件 @
151048bb
...
...
@@ -403,6 +403,9 @@ class Body(metaclass=ABCMeta):
body
=
FixedStar
(
**
body_data
)
else
:
body
=
Body
(
**
body_data
)
# [x, y, z]->[-y, z, x]
# body.init_velocity = [-body.init_velocity[1],body.init_velocity[2],body.init_velocity[0]]
# body.init_position = [-body.init_position[1],body.init_position[2],body.init_position[0]]
bodies
.
append
(
body
)
if
"params"
in
json_data
:
params
=
json_data
[
"params"
]
...
...
bodies/earth.py
浏览文件 @
151048bb
...
...
@@ -22,10 +22,11 @@ class Earth(Body):
天体质量: 5.97237✕10²⁴ kg
平均密度: 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=[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
,
rotation_speed
=
15
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/jupiter.py
浏览文件 @
151048bb
...
...
@@ -22,10 +22,11 @@ class Jupiter(Body):
天体质量: 1.8982✕10²⁷ kg(317.8 M⊕)
平均密度: 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=[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
,
rotation_speed
=
36.2537
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/mars.py
浏览文件 @
151048bb
...
...
@@ -23,8 +23,10 @@ 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=[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
,
rotation_speed
=
14.6223
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/mercury.py
浏览文件 @
151048bb
...
...
@@ -24,8 +24,10 @@ 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.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
,
rotation_speed
=
0.2558
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/moon.py
浏览文件 @
151048bb
...
...
@@ -23,8 +23,10 @@ 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=[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
,
rotation_speed
=
0.5487
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/neptune.py
浏览文件 @
151048bb
...
...
@@ -24,8 +24,10 @@ class Neptune(Body):
"""
def
__init__
(
self
,
name
=
"海王星"
,
mass
=
1.0241e26
,
init_position
=
[
30
*
AU
,
0
,
0
],
init_velocity
=
[
0
,
5.43
,
0
],
# 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
,
rotation_speed
=
22.3463
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/pluto.py
浏览文件 @
151048bb
...
...
@@ -24,8 +24,10 @@ class Pluto(Body):
"""
def
__init__
(
self
,
name
=
"冥王星"
,
mass
=
1.303e22
,
init_position
=
[
40
*
AU
,
0
,
0
],
init_velocity
=
[
0
,
4.7
,
0
],
# 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
,
rotation_speed
=-
2.3474
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/saturn.py
浏览文件 @
151048bb
...
...
@@ -24,8 +24,10 @@ class Saturn(Body):
"""
def
__init__
(
self
,
name
=
"土星"
,
mass
=
5.6834e26
,
init_position
=
[
10
*
AU
,
0
,
0
],
init_velocity
=
[
0
,
9.64
,
0
],
# 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
,
rotation_speed
=
33.7711
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/uranus.py
浏览文件 @
151048bb
...
...
@@ -24,8 +24,10 @@ class Uranus(Body):
"""
def
__init__
(
self
,
name
=
"天王星"
,
mass
=
8.681e25
,
init_position
=
[
19
*
AU
,
0
,
0
],
init_velocity
=
[
0
,
6.81
,
0
],
# 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
,
rotation_speed
=-
20.8816
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
bodies/venus.py
浏览文件 @
151048bb
...
...
@@ -24,8 +24,10 @@ 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.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
,
rotation_speed
=-
0.0617
,
ignore_mass
=
False
,
trail_color
=
None
,
show_name
=
False
):
params
=
{
...
...
common/func.py
浏览文件 @
151048bb
...
...
@@ -64,13 +64,13 @@ def get_positions_velocitys(angles, velocity=1, radius=1, radius_offset=None, ve
velocity
=
velocity
+
np
.
random
.
rand
(
len
(
angles
))
*
velocity_offset
pxs
=
radius
*
np
.
cos
(
angles
)
p
y
s
=
radius
*
np
.
sin
(
angles
)
p
z
s
=
radius
*
np
.
sin
(
angles
)
v
y
s
=
velocity
*
np
.
cos
(
angles
)
v
z
s
=
velocity
*
np
.
cos
(
angles
)
vxs
=
velocity
*
np
.
sin
(
angles
)
# return pxs, p
ys, fxs, fy
s
return
np
.
round
(
pxs
,
2
),
np
.
round
(
p
ys
,
2
),
-
np
.
round
(
vxs
,
2
),
np
.
round
(
vy
s
,
2
)
# return pxs, p
zs, vxs, vz
s
return
np
.
round
(
pxs
,
2
),
np
.
round
(
p
zs
,
2
),
-
np
.
round
(
vxs
,
2
),
np
.
round
(
vz
s
,
2
)
def
find_file
(
file_path
,
default_val
=
None
,
find_deep
=
5
):
...
...
data/gravity_slingshot.json
浏览文件 @
151048bb
...
...
@@ -4,12 +4,12 @@
"name"
:
"太阳"
,
"mass"
:
1.9891e+30
,
"init_position"
:
[
0.0
,
-
0.0
,
0.0
,
0.0
],
"init_velocity"
:
[
0.0
,
-
0.0
,
0.0
,
0.0
],
...
...
@@ -35,14 +35,14 @@
"name"
:
"地球"
,
"mass"
:
5.97237e+24
,
"init_position"
:
[
448793600.0
,
0.0
,
-448793600.0
,
0.0
],
"init_velocity"
:
[
0
.0
,
38
.0
,
-1
.0
-38
.0
,
-1
.0
,
0
.0
],
"density"
:
5507.85
,
"color"
:
[
...
...
data/sun_earth.json
浏览文件 @
151048bb
...
...
@@ -4,12 +4,12 @@
"name"
:
"太阳"
,
"mass"
:
1.9891e+30
,
"init_position"
:
[
0.0
,
-
0.0
,
0.0
,
0.0
],
"init_velocity"
:
[
0.0
,
-
0.0
,
0.0
,
0.0
],
...
...
@@ -35,13 +35,13 @@
"name"
:
"地球"
,
"mass"
:
5.97237e+24
,
"init_position"
:
[
167549616
.0
,
-0
.0
,
0.0
,
0
.0
167549616
.0
],
"init_velocity"
:
[
-29.790000915527344
,
0.0
,
29.790000915527344
,
0.0
],
"density"
:
5507.85
,
...
...
data/sun_earth_moon.json
浏览文件 @
151048bb
...
...
@@ -4,12 +4,12 @@
"name"
:
"太阳"
,
"mass"
:
1.9891e+30
,
"init_position"
:
[
149597872
.0
,
-0
.0
,
0.0
,
0
.0
149597872
.0
],
"init_velocity"
:
[
0.0
,
-
0.0
,
0.0
,
0.0
],
...
...
@@ -24,18 +24,23 @@
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.613
,
"ignore_mass"
:
true
,
"is_fixed_star"
:
true
"is_fixed_star"
:
true
,
"trail_color"
:
[
170
,
98
,
25
]
},
{
"name"
:
"地球"
,
"mass"
:
5.97237e+24
,
"init_position"
:
[
0.0
,
-
0.0
,
0.0
,
0.0
],
"init_velocity"
:
[
0.0
,
-
0.0
,
0.0
,
0.0
],
...
...
@@ -50,19 +55,24 @@
"distance_scale"
:
1.0
,
"rotation_speed"
:
15
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
false
"is_fixed_star"
:
false
,
"trail_color"
:
[
1
,
89
,
162
]
},
{
"name"
:
"月球"
,
"mass"
:
7.342e+22
,
"init_position"
:
[
38440
0.0
,
-
0.0
,
0.0
,
0.0
38440
0.0
],
"init_velocity"
:
[
-1.0230000019073486
,
0.0
,
1.0230000019073486
,
0.0
],
"density"
:
3344.0
,
...
...
@@ -76,7 +86,12 @@
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.5487
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
false
"is_fixed_star"
:
false
,
"trail_color"
:
[
162
,
162
,
162
]
}
],
"params"
:
{
...
...
@@ -85,6 +100,8 @@
0
,
0
,
0
]
],
"show_trail"
:
false
,
"show_name"
:
false
}
}
\ No newline at end of file
data/tri_bodies_perfect_01.json
浏览文件 @
151048bb
...
...
@@ -4,14 +4,14 @@
"name"
:
"红轨太阳A"
,
"mass"
:
2e+30
,
"init_position"
:
[
-518222240.0
,
0.0
,
518222240.0
,
0.0
],
"init_velocity"
:
[
-
14.890000343322754
,
-
0.0
,
0.0
,
0.0
-14.890000343322754
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -19,28 +19,30 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
255
,
0
,
0
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
},
{
"name"
:
"绿轨太阳B"
,
"mass"
:
2e+30
,
"init_position"
:
[
-
299195744
.0
,
-
0
.0
,
0.0
,
0
.0
-299195744
.0
],
"init_velocity"
:
[
7.445000171661377
,
-12.895118713378906
,
0.0
12.895118713378906
,
0.0
,
7.445000171661377
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -48,28 +50,30 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
0
,
255
,
0
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
},
{
"name"
:
"蓝轨太阳C"
,
"mass"
:
2e+30
,
"init_position"
:
[
299195744
.0
,
-0
.0
,
0.0
,
0
.0
299195744
.0
],
"init_velocity"
:
[
7.445000171661377
,
12.895118713378906
,
0.0
-12.895118713378906
,
0.0
,
7.445000171661377
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -77,28 +81,30 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
0
,
0
,
255
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
},
{
"name"
:
"流浪地球"
,
"mass"
:
5.97237e+24
,
"init_position"
:
[
0
.0
,
86370368
.0
,
747989376
.0
-86370368
.0
,
747989376
.0
,
0
.0
],
"init_velocity"
:
[
0.0
,
0.0
,
-1
0.0
-
0.0
,
-1
0.0
,
0.0
],
"density"
:
5507.85
,
"color"
:
[
...
...
@@ -108,7 +114,15 @@
],
"texture"
:
"earth1.jpg"
,
"size_scale"
:
4000.0
,
"distance_scale"
:
1
"distance_scale"
:
1
,
"rotation_speed"
:
null
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
false
,
"trail_color"
:
[
1
,
89
,
162
]
}
],
"params"
:
{
...
...
data/tri_bodies_perfect_02.json
浏览文件 @
151048bb
...
...
@@ -4,14 +4,14 @@
"name"
:
"红轨太阳A"
,
"mass"
:
2e+30
,
"init_position"
:
[
-518222240.0
,
0.0
,
518222240.0
,
0.0
],
"init_velocity"
:
[
-
14.890000343322754
,
-
0.0
,
0.0
,
0.0
-14.890000343322754
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -19,28 +19,30 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
255
,
0
,
0
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
},
{
"name"
:
"绿轨太阳B"
,
"mass"
:
2e+30
,
"init_position"
:
[
-
299195744
.0
,
-
0
.0
,
0.0
,
0
.0
-299195744
.0
],
"init_velocity"
:
[
7.445000171661377
,
-12.895118713378906
,
0.0
12.895118713378906
,
0.0
,
7.445000171661377
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -48,28 +50,30 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
0
,
255
,
0
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
},
{
"name"
:
"蓝轨太阳C"
,
"mass"
:
2e+30
,
"init_position"
:
[
299195744
.0
,
-0
.0
,
0.0
,
0
.0
299195744
.0
],
"init_velocity"
:
[
7.445000171661377
,
12.895118713378906
,
0.0
-12.895118713378906
,
0.0
,
7.445000171661377
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -77,15 +81,17 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
0
,
0
,
255
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
}
],
"params"
:
{
...
...
data/tri_bodies_perfect_03.json
浏览文件 @
151048bb
...
...
@@ -4,14 +4,14 @@
"name"
:
"红轨太阳A"
,
"mass"
:
2e+30
,
"init_position"
:
[
-518222240.0
,
0.0
,
"$exp:math.sqrt(3) * 2 * AU"
,
0.0
],
"init_velocity"
:
[
-
14.89
,
-
0.0
,
0.0
,
0.0
-14.890000343322754
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -19,28 +19,30 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
255
,
0
,
0
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
},
{
"name"
:
"绿轨太阳B"
,
"mass"
:
2e+30
,
"init_position"
:
[
"$exp: -2 * AU"
,
-0.0
,
0.0
,
0
.0
-299195744
.0
],
"init_velocity"
:
[
"$exp: 1/2 * 14.88"
,
"$exp:-math.sqrt(3) / 2 * 14.88"
,
0.0
12.886458396911621
,
0.0
,
7.440000057220459
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -48,28 +50,30 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
0
,
255
,
0
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
},
{
"name"
:
"蓝轨太阳C"
,
"mass"
:
2e+30
,
"init_position"
:
[
"$exp: 2 * AU"
,
-0.0
,
0.0
,
0
.0
299195744
.0
],
"init_velocity"
:
[
"$exp: 1/2 * 14.88"
,
"$exp:math.sqrt(3) / 2 * 14.88"
,
0.0
-12.886458396911621
,
0.0
,
7.440000057220459
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -77,15 +81,17 @@
98
,
25
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"rotation_speed"
:
0.1
,
"ignore_mass"
:
false
,
"is_fixed_star"
:
true
,
"trail_color"
:
[
0
,
0
,
255
],
"texture"
:
"sun2.jpg"
,
"size_scale"
:
50.0
,
"distance_scale"
:
1.0
,
"is_fixed_star"
:
true
]
}
],
"params"
:
{
...
...
data/tri_bodies_perfect_04.json
浏览文件 @
151048bb
...
...
@@ -4,14 +4,14 @@
"name"
:
"红轨太阳A"
,
"mass"
:
2e+30
,
"init_position"
:
[
-518222240.0
,
0.0
,
518222240.0
,
0.0
],
"init_velocity"
:
[
-
12
.0
,
-
0
.0
,
0.0
,
0
.0
-12
.0
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -35,14 +35,14 @@
"name"
:
"绿轨太阳B"
,
"mass"
:
2e+30
,
"init_position"
:
[
-
299195744
.0
,
-
0
.0
,
0.0
,
0
.0
-299195744
.0
],
"init_velocity"
:
[
6.0
,
-10.392304420471191
,
0
.0
10.392304420471191
,
0.0
,
6
.0
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -66,14 +66,14 @@
"name"
:
"蓝轨太阳C"
,
"mass"
:
2e+30
,
"init_position"
:
[
299195744
.0
,
-0
.0
,
0.0
,
0
.0
299195744
.0
],
"init_velocity"
:
[
6.0
,
10.392304420471191
,
0
.0
-10.392304420471191
,
0.0
,
6
.0
],
"density"
:
1408.0
,
"color"
:
[
...
...
data/tri_bodies_perfect_05.json
浏览文件 @
151048bb
...
...
@@ -4,14 +4,14 @@
"name"
:
"红轨太阳A"
,
"mass"
:
2e+30
,
"init_position"
:
[
-518222240.0
,
0.0
,
518222240.0
,
0.0
],
"init_velocity"
:
[
-
19
.0
,
-
0
.0
,
0.0
,
0
.0
-19
.0
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -35,14 +35,14 @@
"name"
:
"绿轨太阳B"
,
"mass"
:
2e+30
,
"init_position"
:
[
-
299195744
.0
,
-
0
.0
,
0.0
,
0
.0
-299195744
.0
],
"init_velocity"
:
[
9.5
,
-16.454483032226562
,
0.0
16.454483032226562
,
0.0
,
9.5
],
"density"
:
1408.0
,
"color"
:
[
...
...
@@ -66,14 +66,14 @@
"name"
:
"蓝轨太阳C"
,
"mass"
:
2e+30
,
"init_position"
:
[
299195744
.0
,
-0
.0
,
0.0
,
0
.0
299195744
.0
],
"init_velocity"
:
[
9.5
,
16.454483032226562
,
0.0
-16.454483032226562
,
0.0
,
9.5
],
"density"
:
1408.0
,
"color"
:
[
...
...
sim_scenes/fiction/fixed_stars.py
浏览文件 @
151048bb
...
...
@@ -48,7 +48,8 @@ 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 = [body.raduis * SIZE_SCALE, (distance_sum + d), AU]
body
.
init_position
=
[
-
(
distance_sum
+
d
),
AU
,
body
.
raduis
*
SIZE_SCALE
]
distance_sum
+=
d
# 使用 ursina 查看的运行效果
...
...
sim_scenes/fiction/sun_dysen_sphere.py
浏览文件 @
151048bb
...
...
@@ -15,7 +15,7 @@ if __name__ == '__main__':
太阳、戴森球
"""
sun
=
Sun
(
size_scale
=
5e1
,
init_velocity
=
[
0
,
2
,
0
])
# 太阳放大 50 倍
sun
=
Sun
(
size_scale
=
5e1
,
init_velocity
=
[
-
2
,
0
,
0
])
# 太阳放大 50 倍
bodies
=
[
sun
,
DysenSphere
(
size_scale
=
5e1
,
parent
=
sun
),
# 戴森球放大 50 倍
...
...
@@ -28,4 +28,4 @@ if __name__ == '__main__':
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_WEEK
,
position
=
(
0
,
AU
/
4
,
-
3
*
AU
),
bg_music
=
"sounds/
universe_02
.mp3"
)
bg_music
=
"sounds/
interstellar
.mp3"
)
sim_scenes/interest/text_bodies.py
浏览文件 @
151048bb
...
...
@@ -26,8 +26,10 @@ 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=[6000 * D, 450 * D, 100 * D], # [ 远+近- , 左+右- , 上+下-]
init_position
=
[
-
450
*
D
,
100
*
D
,
6000
*
D
],
# [ 远+近- , 左+右- , 上+下-]
ignore_mass
=
True
)
bodies
.
append
(
bg
)
# 使用 ursina 查看的运行效果
...
...
sim_scenes/interest/the_eye_of_god.py
浏览文件 @
151048bb
...
...
@@ -25,7 +25,8 @@ 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=[6000 * D, 400 * D, 100 * D], # [ 远+近- , 左+右- , 上+下-]
init_position
=
[
-
400
*
D
,
100
*
D
,
6000
*
D
],
# [ 远+近- , 左+右- , 上+下-]
ignore_mass
=
True
)
bodies
.
append
(
bg
)
...
...
sim_scenes/interest/utils/body_utils.py
浏览文件 @
151048bb
...
...
@@ -43,7 +43,11 @@ def gen_bodies_from_image(pixel_image, params, texture="color_body.png"):
def
get_position
(
pos
,
scale
):
# return get_scaled_body_pos((camera_pos[2], camera_pos[0], camera_pos[1]), pos, scale)
return
get_scaled_body_pos
((
camera_pos
[
2
],
camera_pos
[
1
],
camera_pos
[
0
]),
pos
,
scale
)
# return get_scaled_body_pos((camera_pos[2], camera_pos[1], camera_pos[0]), pos, scale)
return
get_scaled_body_pos
((
camera_pos
[
0
],
camera_pos
[
1
],
camera_pos
[
2
]),
pos
,
scale
)
# # body.init_position = [body.raduis * SIZE_SCALE, (distance_sum + d), AU]
# body.init_position = [-(distance_sum + d), AU, body.raduis * SIZE_SCALE]
# # [ 远+近- , 左+右- , 上+下-]
# return pos[0] + (scale - 1.0) * 300 * (random.randint(90, 110)) * D, pos[1], pos[2]
...
...
@@ -58,7 +62,7 @@ def gen_bodies_from_image(pixel_image, params, texture="color_body.png"):
width
,
height
=
img
.
size
interval_factor
=
20
# 星球间距因子
body_template
=
'ColorBody(name="%s", mass=mass, color=(%d, %d, %d), size_scale=%.4f, '
\
'init_position=get_position([
0, %g * D, %g * D
], %.4f), '
\
'init_position=get_position([
-%g * D, %g * D, 0
], %.4f), '
\
f
'init_velocity=[0, 0, 0], ignore_mass=True, texture="
{
texture
}
").set_light_disable(True)'
bodies_str
=
"["
...
...
sim_scenes/science/gravity_slingshot_1.py
浏览文件 @
151048bb
...
...
@@ -18,10 +18,12 @@ if __name__ == '__main__':
bodies
=
[
Sun
(
size_scale
=
2e1
),
# 太阳放大 20 倍
Earth
(
size_scale
=
1e3
,
# 地球放大 1000 倍
init_position
=
[
0
,
-
3
*
AU
,
0
],
# 地球距离太阳 3 个天文单位
# 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=[0, 38, -1], # 朝向太阳的速度为 38km/s,-1 km/s 是为了防止地球正面对着太阳冲去
init_velocity
=
[
-
38
,
-
1
,
0
],
# 朝向太阳的速度为 38km/s,-1 km/s 是为了防止地球正面对着太阳冲去
# init_velocity=[0, 50, -1],
),
]
...
...
sim_scenes/science/gravity_slingshot_2.py
浏览文件 @
151048bb
...
...
@@ -16,12 +16,13 @@ if __name__ == '__main__':
模拟流浪地球经过木星、土星加速
"""
bodies
=
[
Jupiter
(
size_scale
=
1e2
,
init_position
=
[
0
,
AU
/
4
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 木星放大 100 倍
Saturn
(
size_scale
=
1e2
,
init_position
=
[
AU
/
1.5
,
1.5
*
AU
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 土星放大 100 倍
Jupiter
(
size_scale
=
1e2
,
init_position
=
[
-
AU
/
4
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 木星放大 100 倍
Saturn
(
size_scale
=
1e2
,
init_position
=
[
-
1.5
*
AU
,
0
,
AU
/
1.5
],
init_velocity
=
[
0
,
0
,
0
]),
# 土星放大 100 倍
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=[-1, 10, 0], # 朝向木星的速度为 38km/s,-1 km/s 是为了防止地球正面对着木星冲去
init_velocity
=
[
-
10
,
0
,
-
1
],
# 朝向木星的速度为 38km/s,-1 km/s 是为了防止地球正面对着木星冲去
# init_velocity=[0, 50, -1],
),
]
...
...
sim_scenes/solar_system/earth_at_night.py
浏览文件 @
151048bb
...
...
@@ -17,13 +17,14 @@ if __name__ == '__main__':
https://www.nasa.gov/mission_pages/NPP/news/earth-at-night.html
https://www.nasa.gov/sites/default/files/images/712130main_8246931247_e60f3c09fb_o.jpg
"""
resolution
=
500
resolution
=
50
# resolution = 500
bodies
=
[
Earth
(
texture
=
"earth_at_night_hd.jpg"
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
100
,
ignore_mass
=
True
).
set_resolution
(
resolution
),
Earth
(
texture
=
"earth_hd.jpg"
,
init_position
=
[
0
,
1
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
init_position
=
[
-
10
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
100
,
ignore_mass
=
True
).
set_resolution
(
resolution
)
]
# 使用 ursina 查看的运行效果
...
...
sim_scenes/solar_system/earth_moon.py
浏览文件 @
151048bb
...
...
@@ -14,19 +14,23 @@ 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
bodies
=
[
# sun,
Earth
(
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
EARTH_INIT_VELOCITY
,
0
],
size_scale
=
0.5e1
),
# 地球放大 5 倍,距离保持不变
Moon
(
init_position
=
[
363104
,
0
,
0
],
# 距地距离约: 363104 至 405696 km
init_velocity
=
[
0
,
EARTH_INIT_VELOCITY
+
1.023
,
0
],
size_scale
=
1e1
)
# 月球放大 10 倍,距离保持不变
init_velocity
=
[
-
EARTH_INIT_VELOCITY
,
0
,
0
],
size_scale
=
0.5e1
),
# 地球放大 5 倍,距离保持不变
Moon
(
init_position
=
[
0
,
0
,
363104
],
# 距地距离约: 363104 至 405696 km
init_velocity
=
[
-
(
EARTH_INIT_VELOCITY
+
1.023
),
0
,
0
],
size_scale
=
1e1
)
# 月球放大 10 倍,距离保持不变
]
# mayavi_run(bodies, SECONDS_PER_HALF_DAY / 2, view_azimuth=-45)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_
MONTH
,
position
=
(
-
300000
,
200000
,
-
1300000
),
show_trail
=
True
)
ursina_run
(
bodies
,
SECONDS_PER_
DAY
,
position
=
(
-
300000
,
200000
,
-
1300000
),
show_trail
=
True
)
sim_scenes/solar_system/earth_moon6.py
浏览文件 @
151048bb
...
...
@@ -32,4 +32,4 @@ if __name__ == '__main__':
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
60
,
position
=
(
0
,
0
,
0
),
show_trail
=
True
,
view_closely
=
0.001
)
ursina_run
(
bodies
,
60
,
position
=
(
0
,
0
,
-
4
*
e
.
diameter
),
show_trail
=
True
,
view_closely
=
0.001
)
sim_scenes/solar_system/hd_earth.py
浏览文件 @
151048bb
...
...
@@ -17,11 +17,11 @@ if __name__ == '__main__':
bodies
=
[
Earth
(
texture
=
"earth_hd.jpg"
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
1
00
,
show_name
=
True
)
size_scale
=
1
,
show_name
=
True
)
]
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_HOUR
,
position
=
(
0
,
30000
,
-
200
0000
),
ursina_run
(
bodies
,
SECONDS_PER_HOUR
,
position
=
(
0
,
0
,
-
2
0000
),
# cosmic_bg="textures/cosmic1.jpg",
view_closely
=
True
)
view_closely
=
0.001
)
sim_scenes/solar_system/hd_mercury.py
浏览文件 @
151048bb
...
...
@@ -17,11 +17,11 @@ if __name__ == '__main__':
bodies
=
[
Mercury
(
texture
=
"mercury_hd.tif"
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
1
00
,
show_name
=
True
)
size_scale
=
1
,
show_name
=
True
)
]
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
30000
,
-
800
000
),
ursina_run
(
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
0
,
-
8
000
),
# cosmic_bg="textures/cosmic1.jpg",
view_closely
=
True
)
view_closely
=
0.001
)
sim_scenes/solar_system/hd_pluto.py
浏览文件 @
151048bb
...
...
@@ -7,7 +7,7 @@
# python_version :3.8
# ==============================================================================
from
bodies
import
Pluto
from
common.consts
import
SECONDS_PER_
WEEK
,
SECONDS_PER_DAY
from
common.consts
import
SECONDS_PER_
HOUR
,
SECONDS_PER_DAY
from
sim_scenes.func
import
ursina_run
if
__name__
==
'__main__'
:
...
...
@@ -17,11 +17,11 @@ if __name__ == '__main__':
bodies
=
[
Pluto
(
texture
=
"pluto_hd.jpg"
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
100
,
show_name
=
True
)
size_scale
=
2
,
show_name
=
True
)
]
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_
DAY
,
position
=
(
0
,
10000
,
-
450
000
),
ursina_run
(
bodies
,
SECONDS_PER_
HOUR
,
position
=
(
0
,
0
,
-
9
000
),
# cosmic_bg="textures/cosmic1.jpg",
view_closely
=
True
)
view_closely
=
0.001
)
sim_scenes/solar_system/hd_venus.py
浏览文件 @
151048bb
...
...
@@ -17,11 +17,11 @@ if __name__ == '__main__':
bodies
=
[
Venus
(
texture
=
"venus_hd.jpg"
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
1
00
,
show_name
=
True
)
size_scale
=
1
,
show_name
=
True
)
]
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
30000
,
-
150
0000
),
ursina_run
(
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
0
,
-
2
0000
),
# cosmic_bg="textures/cosmic1.jpg",
view_closely
=
True
)
view_closely
=
0.001
)
sim_scenes/solar_system/solar_system_1.py
浏览文件 @
151048bb
...
...
@@ -20,7 +20,7 @@ if __name__ == '__main__':
# 以下展示的效果为太阳系真实的距离
# 由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大
sun
=
Sun
(
name
=
"太阳"
,
size_scale
=
0.8e2
)
# 太阳放大 80 倍,距离保持不变
# sun.init_velocity = [0,
0, 2]
# 太阳带着其他行星一起跑
# sun.init_velocity = [0,
2, 0]
# 太阳带着其他行星一起跑
bodies
=
[
sun
,
Mercury
(
name
=
"水星"
,
size_scale
=
4e3
),
# 水星放大 4000 倍,距离保持不变
...
...
sim_scenes/solar_system/solar_system_3.py
浏览文件 @
151048bb
...
...
@@ -49,16 +49,16 @@ if __name__ == '__main__':
NUM_OF_ASTEROIDS
=
10
asteroids
=
[]
angles
=
np
.
linspace
(
0
,
100
*
np
.
pi
,
NUM_OF_ASTEROIDS
)
pxs
,
p
ys
,
vxs
,
vy
s
=
get_positions_velocitys
(
angles
,
pxs
,
p
zs
,
vxs
,
vz
s
=
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
):
p
y
,
fx
,
fy
=
pys
[
i
],
vxs
[
i
],
vy
s
[
i
]
p
z
,
fx
,
fz
=
pzs
[
i
],
vxs
[
i
],
vz
s
[
i
]
asteroids
.
append
(
Asteroid
(
size_scale
=
3e9
,
# 小行星放大 5000000000 倍,距离放大 1.4 倍
init_position
=
[
px
,
py
,
0
],
init_velocity
=
[
fx
,
fy
,
0
],
init_position
=
[
px
,
0
,
pz
],
init_velocity
=
[
fx
,
0
,
fz
],
distance_scale
=
1.4
))
# endregion 2
...
...
sim_scenes/solar_system/sun_earth_moon.py
浏览文件 @
151048bb
...
...
@@ -17,18 +17,18 @@ if __name__ == '__main__':
"""
# 地球的Y方向初始速度
EARTH_INIT_VELOCITY
=
0
# 0km/s
sun
=
Sun
(
init_position
=
[
AU
,
0
,
0
],
size_scale
=
2e1
)
# 太阳放大 20 倍
# 忽略质量的引力
sun
=
Sun
(
init_position
=
[
0
,
0
,
AU
],
size_scale
=
2e1
)
# 太阳放大 20 倍
# 忽略质量的引力
[x, y, z]->[-y, z, x]
sun
.
ignore_mass
=
True
# 观看月相变化的过程:分别是 新月、蛾眉月、上弦月、盈凸、满月、亏凸、下弦月、残月
# 参考:images/moon/月相变化过程.jpeg
# TODO: 月球在摄像机的前方(从 “新月” 开始)
moon_pos
,
moon_vel
=
[
384400
,
0
,
0
],
[
0
,
EARTH_INIT_VELOCITY
+
1.023
,
0
]
# TODO: 月球在摄像机的右方(从 “下弦月” 开始),将会出现
# moon_pos, moon_vel = [
0, -384400, 0], [1.023, EARTH_INIT_VELOCITY, 0
]
# TODO: 月
月
球在摄像机的左方(从 “上弦月” 开始)
# moon_pos, moon_vel = [0, 384400, 0], [-1.023, EARTH_INIT_VELOCITY, 0
]
# moon_pos, moon_vel = [0, 0, 384400], [-(EARTH_INIT_VELOCITY + 1.023), 0
, 0]
# TODO: 月球在摄像机的右方(从 “下弦月” 开始),将会
从右方
出现
# moon_pos, moon_vel = [
384400, 0, 0], [-EARTH_INIT_VELOCITY, 0, 1.023
]
# TODO: 月球在摄像机的左方(从 “上弦月” 开始)
moon_pos
,
moon_vel
=
[
-
384400
,
0
,
0
],
[
EARTH_INIT_VELOCITY
,
0
,
-
1.023
]
bodies
=
[
sun
,
...
...
sim_scenes/tri_bodies/tri_bodies_perfect.py
浏览文件 @
151048bb
...
...
@@ -27,6 +27,7 @@ if __name__ == '__main__':
# 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
],
...
...
sim_scenes/tri_bodies/two_bodies_01.py
浏览文件 @
151048bb
...
...
@@ -19,9 +19,9 @@ if __name__ == '__main__':
3、天体质量 mass
"""
bodies
=
[
Sun
(
mass
=
1.5e30
,
init_position
=
[
849597870
.700
,
0
,
0
],
init_velocity
=
[
0
,
7.0
,
0
]
,
Sun
(
mass
=
1.5e30
,
init_position
=
[
849597870
,
0
,
0
],
init_velocity
=
[
0
,
7.0
,
0
],
trail_color
=
(
255
,
0
,
0
)
,
size_scale
=
5e1
,
texture
=
"sun1.jpg"
),
# 太阳放大 100 倍
Sun
(
mass
=
2
e30
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
-
8.0
,
0
],
Sun
(
mass
=
1.5
e30
,
init_position
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
-
8.0
,
0
],
size_scale
=
5e1
,
texture
=
"sun2.jpg"
),
# 太阳放大 100 倍
Earth
(
init_position
=
[
0
,
349597870.700
,
0
],
init_velocity
=
[
10.50
,
0
,
0
],
size_scale
=
4e3
,
distance_scale
=
1
),
# 地球放大 4000 倍,距离保持不变
...
...
@@ -33,4 +33,4 @@ if __name__ == '__main__':
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
AU
,
2
*
AU
,
-
7
*
AU
),
show_trail
=
True
)
\ No newline at end of file
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
1.5
*
AU
,
0
,
-
7
*
AU
),
show_trail
=
True
)
\ No newline at end of file
sim_scenes/ursina_json_sim.py
浏览文件 @
151048bb
...
...
@@ -29,7 +29,7 @@ if __name__ == '__main__':
# TODO: 去掉注释,完美数据的三体模型的演示05(画大花)
# bodies, params = Body.build_bodies_from_json('../data/tri_bodies_perfect_05.json')
# TODO: 去掉注释,引力弹弓的演示
#
bodies, params = Body.build_bodies_from_json('../data/gravity_slingshot.json')
bodies
,
params
=
Body
.
build_bodies_from_json
(
'../data/gravity_slingshot.json'
)
dt
=
params
[
"dt"
]
if
"dt"
in
params
else
SECONDS_PER_YEAR
position
=
params
[
"position"
]
if
"position"
in
params
else
(
0
,
0
,
0
)
...
...
simulators/ursina/entities/body_trail.py
浏览文件 @
151048bb
...
...
@@ -40,5 +40,14 @@ class BodyTrail(Entity):
v_arrow
,
v_line
,
v_text
=
create_arrow_line
((
0
,
0
,
0
),
tuple
(
vel_direction
),
parent
=
self
,
label
=
vel_info
,
color
=
color
.
red
,
alpha
=
0.8
,
arrow_scale
=
0.5
)
if
str
(
vel_info
).
startswith
(
"0.00"
):
v_text
.
parent
=
self
v_arrow
.
enabled
=
False
v_line
.
enabled
=
False
a_arrow
,
a_line
,
a_text
=
create_arrow_line
((
0
,
0
,
0
),
tuple
(
acc_direction
),
parent
=
self
,
label
=
acc_info
,
color
=
color
.
yellow
,
alpha
=
0.8
,
arrow_scale
=
0.5
)
if
str
(
acc_info
).
startswith
(
"0.00"
):
a_text
.
parent
=
self
a_arrow
.
enabled
=
False
a_line
.
enabled
=
False
simulators/ursina/entities/entity_utils.py
浏览文件 @
151048bb
...
...
@@ -173,7 +173,7 @@ def clear_trails(self):
self
.
trails
.
clear
()
def
create_fixed_star_lights
(
parent
):
def
create_fixed_star_lights
(
fixed_star
):
"""
创建恒星的发光的效果、并作为灯光源
:param entity:
...
...
@@ -181,14 +181,14 @@ def create_fixed_star_lights(parent):
"""
# 如果是恒星(如:太阳),自身会发光,则需要关闭灯光
parent
.
set_light_off
()
fixed_star
.
set_light_off
()
# lights = []
# # 创建多个新的 Entity 对象,作为光晕的容器
# _color = color.rgba(1.0, 0.6, 0.2, 1)
if
hasattr
(
parent
.
body_view
.
body
,
"glows"
):
if
hasattr
(
fixed_star
.
body_view
.
body
,
"glows"
):
# glows = (glow_num:10, glow_scale:1.03 glow_alpha:0.1~1)
glows
=
parent
.
body_view
.
body
.
glows
glows
=
fixed_star
.
body_view
.
body
.
glows
if
glows
is
not
None
:
if
isinstance
(
glows
,
tuple
):
if
len
(
glows
)
==
3
:
...
...
@@ -210,16 +210,16 @@ def create_fixed_star_lights(parent):
glow_alpha
=
glow_alphas
[
-
1
]
# _color = color.white
_color
=
parent
.
body_view
.
body
.
color
_color
=
fixed_star
.
body_view
.
body
.
color
_color
=
color
.
rgba
(
_color
[
0
]
/
255
,
_color
[
1
]
/
255
,
_color
[
2
]
/
255
,
1
)
for
i
in
range
(
glow_num
):
glow_entity
=
Entity
(
parent
=
parent
,
model
=
'sphere'
,
color
=
_color
,
glow_entity
=
Entity
(
parent
=
fixed_star
,
model
=
'sphere'
,
color
=
_color
,
scale
=
math
.
pow
(
glow_scale
,
i
+
1
),
alpha
=
glow_alpha
)
if
hasattr
(
parent
.
body_view
.
body
,
"light_on"
):
if
parent
.
body_view
.
body
.
light_on
:
if
hasattr
(
fixed_star
.
body_view
.
body
,
"light_on"
):
if
fixed_star
.
body_view
.
body
.
light_on
:
for
i
in
range
(
2
):
# 创建 PointLight 对象,作为恒星的灯光源
light
=
PointLight
(
parent
=
parent
,
intensity
=
10
,
range
=
10
,
color
=
color
.
white
)
light
=
PointLight
(
parent
=
fixed_star
,
intensity
=
10
,
range
=
10
,
color
=
color
.
white
)
def
merge_vectors
(
vectors
):
...
...
@@ -229,11 +229,11 @@ def merge_vectors(vectors):
# 计算速度的方向
direction
=
(
x
/
value
,
y
/
value
,
z
/
value
)
# 返回速度大小和速度方向
#
return value, direction
return
value
,
direction
# return value, (direction[1], direction[0], direction[2])
# return value, (direction[1], direction[2], direction[0])
return
value
,
(
-
direction
[
1
],
direction
[
2
],
direction
[
0
])
#
return value, (-direction[1], direction[2], direction[0])
def
create_trail_info
(
body
,
trail
):
...
...
@@ -256,10 +256,10 @@ def create_trail_info(body, trail):
acc_direction
=
np
.
array
(
acc_direction
)
*
2
vel_position
=
vel_direction
vel_position
=
(
vel_position
[
0
],
vel_position
[
1
],
vel_position
[
2
])
#
vel_position = (vel_position[0], vel_position[1], vel_position[2])
acc_position
=
acc_direction
acc_position
=
(
acc_position
[
0
],
acc_position
[
1
],
acc_position
[
2
])
#
acc_position = (acc_position[0], acc_position[1], acc_position[2])
trail
.
entity_infos
=
{
"velocity"
:
[
vel_info
,
vel_direction
,
vel_position
],
"acceleration"
:
[
acc_info
,
acc_direction
,
acc_position
]}
...
...
simulators/ursina/entities/planet.py
浏览文件 @
151048bb
...
...
@@ -100,7 +100,7 @@ class Planet(Entity):
# 创建行星环(目前只有土星环)
create_rings
(
self
)
def
turn
(
self
):
def
update
(
self
):
if
hasattr
(
self
.
body
,
"torus_stars"
):
# 星环小天体群(主要模拟小行星群,非一个天体)不受 body_size_factor 影响
self
.
scale
=
self
.
init_scale
...
...
@@ -110,9 +110,12 @@ class Planet(Entity):
pos
=
self
.
body_view
.
position
*
UrsinaConfig
.
SCALE_FACTOR
if
self
.
body
.
parent
is
None
:
# TODO: ????????
self
.
x
=
-
pos
[
1
]
self
.
y
=
pos
[
2
]
self
.
z
=
pos
[
0
]
# self.x = -pos[1]
# self.y = pos[2]
# self.z = pos[0]
self
.
x
=
pos
[
0
]
self
.
y
=
pos
[
1
]
self
.
z
=
pos
[
2
]
else
:
self
.
follow_parent
()
...
...
@@ -146,12 +149,13 @@ class Planet(Entity):
self
.
rotation_y
,
self
.
rotation_z
)
if
UrsinaConfig
.
show_trail
:
# 有时候第一个位置不正确,所以判断一下有历史记录后在创建
if
len
(
self
.
body
.
his_position
())
>
1
:
create_trails
(
self
)
else
:
clear_trails
(
self
)
if
not
hasattr
(
self
.
body
,
"show_trail"
)
or
self
.
body
.
show_trail
:
if
UrsinaConfig
.
show_trail
:
# 有时候第一个位置不正确,所以判断一下有历史记录后在创建
if
len
(
self
.
body
.
his_position
())
>
1
:
create_trails
(
self
)
else
:
clear_trails
(
self
)
if
hasattr
(
self
,
"name_text"
):
d
=
(
camera
.
world_position
-
self
.
name_text
.
world_position
).
length
()
...
...
@@ -177,9 +181,12 @@ class Planet(Entity):
break
pos
=
self
.
f_parent
.
position
*
UrsinaConfig
.
SCALE_FACTOR
# TODO: ????????
self
.
x
=
-
pos
[
1
]
self
.
y
=
pos
[
2
]
self
.
z
=
pos
[
0
]
# self.x = -pos[1]
# self.y = pos[2]
# self.z = pos[0]
self
.
x
=
pos
[
0
]
self
.
y
=
pos
[
1
]
self
.
z
=
pos
[
2
]
def
destroy_all
(
self
):
# 从天体系统中移除自己(TODO:暂时还不能移除)
...
...
simulators/ursina/ursina_mesh.py
浏览文件 @
151048bb
...
...
@@ -92,7 +92,7 @@ def create_arrow(height=0.5, width=0.1):
def
create_arrow_line
(
from_pos
,
to_pos
,
parent
=
None
,
label
=
None
,
set_light_off
=
True
,
alpha
=
1.0
,
set_light_off
=
True
,
alpha
=
1.0
,
len_scale
=
0.5
,
color
=
color
.
white
,
thickness
=
2
,
arrow_scale
=
1
,
text_scale
=
50
):
"""
...
...
@@ -103,6 +103,7 @@ def create_arrow_line(from_pos, to_pos, parent=None, label=None,
@param label: 箭头显示的文字
@param set_light_off: 是否设置为灯光关闭状态
@param alpha: 透明度
@param len_scale: 长度缩放
@param color: 箭头线颜色
@param thickness: 线段粗细
@param arrow_scale: 箭头缩放
...
...
@@ -111,12 +112,13 @@ def create_arrow_line(from_pos, to_pos, parent=None, label=None,
height
=
0.5
*
thickness
width
=
0.1
*
thickness
arrow_mesh
=
create_arrow
(
height
,
width
)
verts
=
(
Vec3
(
from_pos
),
Vec3
(
to_pos
))
line
=
Entity
(
parent
=
parent
,
model
=
Mesh
(
vertices
=
verts
,
mode
=
'line'
,
thickness
=
thickness
),
from_pos
,
to_pos
=
(
Vec3
(
from_pos
),
Vec3
(
to_pos
))
line
=
Entity
(
parent
=
parent
,
model
=
Mesh
(
vertices
=
(
from_pos
*
len_scale
,
to_pos
*
len_scale
),
mode
=
'line'
,
thickness
=
thickness
),
color
=
color
,
alpha
=
alpha
)
arrow
=
Entity
(
parent
=
line
,
model
=
arrow_mesh
,
position
=
verts
[
1
]
,
arrow
=
Entity
(
parent
=
line
,
model
=
arrow_mesh
,
position
=
to_pos
*
len_scale
,
scale
=
thickness
*
arrow_scale
,
color
=
color
,
alpha
=
alpha
)
arrow
.
look_at
(
Vec3
(
to_pos
)
*
100
)
arrow
.
look_at
(
to_pos
*
100
)
if
set_light_off
:
line
.
set_light_off
()
...
...
simulators/views/ursina_view.py
浏览文件 @
151048bb
...
...
@@ -31,7 +31,7 @@ class UrsinaView(BodyView):
:return:
"""
self
.
planet
.
turn
()
self
.
planet
.
update
()
def
appear
(
self
):
pass
...
...
sounds/interstellar.mp3
0 → 100644
浏览文件 @
151048bb
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录