Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
8978610a
宇宙模拟器
项目概览
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看板
提交
8978610a
编写于
4月 25, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
0ae2e9a5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
72 addition
and
16 deletion
+72
-16
sim_lab/research_calc.py
sim_lab/research_calc.py
+68
-15
simulators/ursina/entities/planet.py
simulators/ursina/entities/planet.py
+4
-1
未找到文件。
sim_lab/research_calc.py
浏览文件 @
8978610a
...
@@ -31,21 +31,60 @@ def get_lagrangian_points(m1, m2, r):
...
@@ -31,21 +31,60 @@ def get_lagrangian_points(m1, m2, r):
return
l1
,
l2
,
l3
,
l4
,
l5
return
l1
,
l2
,
l3
,
l4
,
l5
def
create_satellite
(
name
,
init_position
,
init_velocity
):
satellite
=
Satellite
(
name
=
name
,
mass
=
1.4e10
,
size_scale
=
3e3
,
color
=
(
255
,
200
,
0
),
init_position
=
init_position
,
init_velocity
=
init_velocity
,
gravity_only_for
=
[
earth
,
moon
])
return
satellite
bodies
=
[
bodies
=
[
Earth
(
init_position
=
[
0
,
0
,
0
],
texture
=
"earth_hd.jpg"
,
Earth
(
init_position
=
[
0
,
0
,
0
],
texture
=
"earth_hd.jpg"
,
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
0.5e1
),
# 地球放大 5 倍,距离保持不变
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
0.5e1
),
# 地球放大 5 倍,距离保持不变
Moon
(
init_position
=
[
0
,
0
,
363104
],
# 距地距离约: 363104 至 405696 km
Moon
(
init_position
=
[
0
,
0
,
363104
],
# 距地距离约: 363104 至 405696 km
init_velocity
=
[
-
1.054152222
,
0
,
0
],
size_scale
=
1e1
)
# 月球放大 10 倍,距离保持不变
init_velocity
=
[
-
1.054152222
,
0
,
0
],
size_scale
=
1e1
)
# 月球放大 10 倍,距离保持不变
]
]
import
math
earth
=
bodies
[
0
]
earth
=
bodies
[
0
]
moon
=
bodies
[
1
]
moon
=
bodies
[
1
]
L1_p
,
L2_p
,
L3_p
,
L4_p
,
L5_p
=
get_lagrangian_points
(
earth
.
mass
,
moon
.
mass
,
363104
)
# L1_p, L2_p, L3_p, L4_p, L5_p = get_lagrangian_points(earth.mass, moon.mass, 363104)
point_z
=
L1_p
[
2
]
+
3301.0505
# 越大,离月球越近
# point_z = L4_p[2] + 0 # 越大,离月球越近
init_velocity
=
[
-
0.890211
,
0
,
0
]
# L4_vel = 1.048
satellite
=
Satellite
(
name
=
f
'卫星'
,
mass
=
1.4e10
,
size_scale
=
1e3
,
color
=
(
255
,
200
,
0
),
# init_velocity = [-math.sin(math.pi * 30 / 180)*L4_vel, 0, math.cos(math.pi * 30 / 180)*L4_vel]
init_position
=
[
L1_p
[
0
],
L1_p
[
1
],
point_z
],
init_velocity
=
init_velocity
,
gravity_only_for
=
[
earth
,
moon
])
# point_z = L1_p[2] + 3301.48891 # 越大,离月球越近 3301.48891
bodies
.
append
(
satellite
)
# init_velocity = [-0.890136271716, 0, 0] # -0.890136271716 画图比较好
# L1:point=[0,0,308536.70059015526] velocity=[-0.890136271716, 0, 0]
satelliteL1
=
create_satellite
(
name
=
f
'卫星L1'
,
init_position
=
[
0
,
0
,
308536.672
],
init_velocity
=
[
-
0.890136271716
,
0
,
0
])
bodies
.
append
(
satelliteL1
)
# point_z = L2_p[2] + 2365.72 # 越大,离月球越近
# init_velocity = [-1.24, 0, 0]
# L2:point=[0,0, 423338.5083198447] velocity=[-1.24, 0, 0]
satelliteL2
=
create_satellite
(
name
=
f
'卫星L2'
,
init_position
=
[
0
,
0
,
423338.5083198447
],
init_velocity
=
[
-
1.24
,
0
,
0
])
bodies
.
append
(
satelliteL2
)
# L3:point=[0,0, -364941.3043941873] velocity=[1.039 , 0, 0]
satelliteL3
=
create_satellite
(
name
=
f
'卫星L3'
,
init_position
=
[
0
,
0
,
-
364941.3043941873
],
init_velocity
=
[
1.048
,
0
,
0
])
bodies
.
append
(
satelliteL3
)
L4_vel
=
1.048
L4_init_velocity
=
[
-
math
.
sin
(
math
.
pi
*
30
/
180
)
*
L4_vel
,
0
,
math
.
cos
(
math
.
pi
*
30
/
180
)
*
L4_vel
]
# L4:point=[0,0, 177142.46945395062] velocity=[1.039 , 0, 0]
satelliteL4
=
create_satellite
(
name
=
f
'卫星L4'
,
init_position
=
[
314457.2882157448
,
0
,
177142.46945395062
],
init_velocity
=
L4_init_velocity
)
bodies
.
append
(
satelliteL4
)
L5_vel
=
1.048
L5_init_velocity
=
[
-
math
.
sin
(
math
.
pi
*
30
/
180
)
*
L5_vel
,
0
,
-
math
.
cos
(
math
.
pi
*
30
/
180
)
*
L5_vel
]
# L4:point=[0,0, 177142.46945395062] velocity=[1.039 , 0, 0]
satelliteL5
=
create_satellite
(
name
=
f
'卫星L5'
,
init_position
=
[
-
314457.2882157448
,
0
,
177142.46945395062
],
init_velocity
=
L5_init_velocity
)
bodies
.
append
(
satelliteL5
)
def
calc_simulator
(
target
):
def
calc_simulator
(
target
):
...
@@ -117,11 +156,24 @@ def ursina_simulator():
...
@@ -117,11 +156,24 @@ def ursina_simulator():
# 摄像机看向地球
# 摄像机看向地球
camera_look_at
(
moon
)
camera_look_at
(
moon
)
def
create_connecting_lines
(
satellites_list
):
lines
=
[]
for
satellites
in
satellites_list
:
line
=
create_line
(
from_pos
=
satellites
[
0
].
planet
.
position
,
to_pos
=
satellites
[
1
].
planet
.
position
,
alpha
=
0.3
)
lines
.
append
(
line
)
return
lines
def
on_timer_changed
(
time_data
:
TimeData
):
def
on_timer_changed
(
time_data
:
TimeData
):
from
ursina
import
destroy
from
ursina
import
destroy
if
hasattr
(
earth
,
"line"
):
if
hasattr
(
earth
,
"lines"
):
destroy
(
earth
.
line
)
for
line
in
earth
.
lines
:
earth
.
line
=
create_line
(
from_pos
=
earth
.
planet
.
position
,
to_pos
=
moon
.
planet
.
main_entity
.
position
)
destroy
(
line
)
earth
.
lines
=
create_connecting_lines
([[
satelliteL2
,
satelliteL3
],
[
satelliteL4
,
satelliteL1
],
[
satelliteL5
,
satelliteL1
],
[
satelliteL4
,
satelliteL2
],
[
satelliteL5
,
satelliteL2
],
[
satelliteL4
,
satelliteL3
],
[
satelliteL5
,
satelliteL3
],
])
# 订阅事件后,上面的函数功能才会起作用
# 订阅事件后,上面的函数功能才会起作用
# 运行前会触发 on_ready
# 运行前会触发 on_ready
...
@@ -135,11 +187,12 @@ def ursina_simulator():
...
@@ -135,11 +187,12 @@ def ursina_simulator():
ursina_run
(
bodies
,
SECONDS_PER_HOUR
*
10
,
ursina_run
(
bodies
,
SECONDS_PER_HOUR
*
10
,
position
=
(
-
300000
,
1500000
,
-
100
),
position
=
(
-
300000
,
1500000
,
-
100
),
show_timer
=
True
,
show_timer
=
True
,
show_trail
=
True
)
# show_trail=True
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
calc_simulator
(
earth
)
#
calc_simulator(earth)
calc_simulator
(
moon
)
#
calc_simulator(moon)
calc_simulator
(
satellite
)
#
calc_simulator(satellite)
#
ursina_simulator()
ursina_simulator
()
simulators/ursina/entities/planet.py
浏览文件 @
8978610a
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
# python_version :3.8
# python_version :3.8
# ==============================================================================
# ==============================================================================
# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina
# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ursina
from
ursina
import
Entity
,
camera
,
color
,
Vec3
,
Text
,
load_texture
,
destroy
,
PointLight
from
ursina
import
application
,
Entity
,
camera
,
color
,
Vec3
,
Text
,
load_texture
,
destroy
,
PointLight
from
simulators.ursina.entities.entity_utils
import
create_name_text
,
create_trails
,
clear_trails
,
create_rings
,
\
from
simulators.ursina.entities.entity_utils
import
create_name_text
,
create_trails
,
clear_trails
,
create_rings
,
\
trail_init
,
create_fixed_star_lights
trail_init
,
create_fixed_star_lights
...
@@ -202,6 +202,9 @@ class Planet(Entity):
...
@@ -202,6 +202,9 @@ class Planet(Entity):
def
update
(
self
):
def
update
(
self
):
self
.
change_body_scale
()
self
.
change_body_scale
()
if
application
.
paused
:
return
pos
=
self
.
body_view
.
position
*
UrsinaConfig
.
SCALE_FACTOR
pos
=
self
.
body_view
.
position
*
UrsinaConfig
.
SCALE_FACTOR
if
self
.
body
.
parent
is
None
:
if
self
.
body
.
parent
is
None
:
# self.x = -pos[1]
# self.x = -pos[1]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录