Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
e97bf3ae
宇宙模拟器
项目概览
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看板
提交
e97bf3ae
编写于
6月 24, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
7a6935fb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
19 deletion
+43
-19
common/func.py
common/func.py
+30
-10
sim_scenes/fiction/earth_orbit_stopped.py
sim_scenes/fiction/earth_orbit_stopped.py
+13
-9
未找到文件。
common/func.py
浏览文件 @
e97bf3ae
...
@@ -108,6 +108,26 @@ def calculate_distance(pos1, pos2=[0, 0, 0]):
...
@@ -108,6 +108,26 @@ def calculate_distance(pos1, pos2=[0, 0, 0]):
pow
(
np
.
array
(
pos1
[
2
])
-
np
.
array
(
pos2
[
2
]),
2
),
1
/
2
)
pow
(
np
.
array
(
pos1
[
2
])
-
np
.
array
(
pos2
[
2
]),
2
),
1
/
2
)
return
d
return
d
def
get_acceleration_info
(
acc_value
):
"""
@param acc_value: 加速度的值(km/s²)
@return:
"""
acc_m
=
acc_value
*
1000
# 加速度的值(m/s²)
if
acc_m
>=
0.01
:
acc_info
=
"%.2f m/s²"
%
(
acc_m
)
elif
acc_m
>=
0.00001
:
acc_info
=
"%.2f mm/s²"
%
(
acc_m
*
1000
)
# elif acc_m >= 0.00000001:
# acc_info = "%.2fμm/s²" % (acc_m * 1000 * 1000)
else
:
acc_info
=
"0 m/s²"
return
acc_info
#
#
# def calculate_velocity(mass, semimajor_axis, eccentricity):
# def calculate_velocity(mass, semimajor_axis, eccentricity):
# """
# """
...
@@ -244,16 +264,16 @@ def calculate_distance(pos1, pos2=[0, 0, 0]):
...
@@ -244,16 +264,16 @@ def calculate_distance(pos1, pos2=[0, 0, 0]):
# r = 363104*1000
# r = 363104*1000
# m = 5.97e24
# m = 5.97e24
# print(get_v(M, m, r))
# print(get_v(M, m, r))
# import math
# import math
#
#
# G = 6.67e-11 # 引力常数,单位为N·m²/kg²
# G = 6.67e-11 # 引力常数,单位为N·m²/kg²
# M = 1.99e30 # 太阳质量,单位为kg
# M = 1.99e30 # 太阳质量,单位为kg
# # m = 5.97e24 # 地球质量,单位为kg
# # m = 5.97e24 # 地球质量,单位为kg
# r = 1.5e11 # 地球到太阳的距离,单位为米
# r = 1.5e11 # 地球到太阳的距离,单位为米
#
#
# v = math.sqrt(G * M / r) # 计算地球的线速度,单位为米/秒
# v = math.sqrt(G * M / r) # 计算地球的线速度,单位为米/秒
#
#
# print("天体的线速度为:%.2f 公里/秒" % (v / 1000))
# print("天体的线速度为:%.2f 公里/秒" % (v / 1000))
# # print(calculate_distance([6, 8, 0], [3, 4, 0]))
# # print(calculate_distance([6, 8, 0], [3, 4, 0]))
# # print(find_file("common/func.py"))
# # print(find_file("common/func.py"))
#
#
...
...
sim_scenes/fiction/earth_orbit_stopped.py
浏览文件 @
e97bf3ae
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
# ==============================================================================
# ==============================================================================
from
bodies
import
Sun
,
Earth
,
Mercury
,
Venus
from
bodies
import
Sun
,
Earth
,
Mercury
,
Venus
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
common.func
import
calculate_distance
from
common.func
import
calculate_distance
,
get_acceleration_info
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
camera_look_at
,
two_bodies_colliding
,
set_camera_parent
,
\
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
camera_look_at
,
two_bodies_colliding
,
set_camera_parent
,
\
create_text_panel
create_text_panel
from
bodies.body
import
AU
from
bodies.body
import
AU
...
@@ -57,7 +57,7 @@ class EarthOrbitStoppedSim:
...
@@ -57,7 +57,7 @@ class EarthOrbitStoppedSim:
self
.
arrived_sun
=
None
self
.
arrived_sun
=
None
self
.
arrived_mercury_orbit_line
=
None
self
.
arrived_mercury_orbit_line
=
None
self
.
arrived_venus_orbit_line
=
None
self
.
arrived_venus_orbit_line
=
None
self
.
arrived_info
=
"
距离太阳表面:${distance}
\n\n
地球当前速度:${speed}
"
self
.
arrived_info
=
"
距离太阳表面:${distance}
\n\n
地球当前速度:${speed}
\n\n
地球当前加速度:${acceleration}
\n\n
"
def
create_orbit_line
(
self
,
radius
,
color
):
def
create_orbit_line
(
self
,
radius
,
color
):
orbit_line
=
create_circle_line
(
parent
=
self
.
sun
,
radius
=
radius
,
thickness
=
5
,
color
=
color
,
alpha
=
0.3
)
orbit_line
=
create_circle_line
(
parent
=
self
.
sun
,
radius
=
radius
,
thickness
=
5
,
color
=
color
,
alpha
=
0.3
)
...
@@ -85,13 +85,16 @@ class EarthOrbitStoppedSim:
...
@@ -85,13 +85,16 @@ class EarthOrbitStoppedSim:
earth_pos
=
self
.
earth
.
planet
.
world_position
earth_pos
=
self
.
earth
.
planet
.
world_position
camera
.
world_position
=
Vec3
(
earth_pos
[
0
],
earth_pos
[
1
]
+
0.01
,
earth_pos
[
2
]
-
0.1
)
camera
.
world_position
=
Vec3
(
earth_pos
[
0
],
earth_pos
[
1
]
+
0.01
,
earth_pos
[
2
]
-
0.1
)
acceleration_info
=
get_acceleration_info
(
self
.
earth
.
acceleration
[
2
])
if
two_bodies_colliding
(
self
.
sun
,
self
.
earth
):
if
two_bodies_colliding
(
self
.
sun
,
self
.
earth
):
self
.
arrived_sun
=
True
self
.
arrived_sun
=
True
msg
=
"地球在[%s]到达太阳表面"
%
time_data
.
time_text
msg
=
"地球在[%s]到达太阳表面"
%
time_data
.
time_text
print
(
msg
)
print
(
msg
)
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
replace
(
"${distance}"
,
"0 公里"
).
\
replace
(
"${distance}"
,
"0 km"
).
\
replace
(
"${speed}"
,
"%s 公里/秒"
%
round
(
self
.
earth
.
velocity
[
2
],
2
))
\
replace
(
"${acceleration}"
,
"%s"
%
acceleration_info
).
\
replace
(
"${speed}"
,
"%s km/s"
%
round
(
self
.
earth
.
velocity
[
2
],
2
))
\
+
"
\n\n
"
+
msg
+
"
\n\n
"
+
msg
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=-
1
)
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=-
1
)
application
.
pause
()
application
.
pause
()
...
@@ -128,17 +131,18 @@ class EarthOrbitStoppedSim:
...
@@ -128,17 +131,18 @@ class EarthOrbitStoppedSim:
distance
=
distance
-
self
.
sun
.
raduis
-
self
.
earth
.
raduis
distance
=
distance
-
self
.
sun
.
raduis
-
self
.
earth
.
raduis
if
distance
>
10000000
:
if
distance
>
10000000
:
distance_str
=
"%s
千万"
%
round
(
distance
/
10000000.0
,
3
)
distance_str
=
"%s千万"
%
round
(
distance
/
10000000.0
,
3
)
elif
distance
>
1000000
:
elif
distance
>
1000000
:
distance_str
=
"%s
百万"
%
round
(
distance
/
1000000.0
,
2
)
distance_str
=
"%s百万"
%
round
(
distance
/
1000000.0
,
2
)
elif
distance
>
10000
:
elif
distance
>
10000
:
distance_str
=
"%s
万"
%
round
(
distance
/
10000.0
,
2
)
distance_str
=
"%s万"
%
round
(
distance
/
10000.0
,
2
)
else
:
else
:
distance_str
=
round
(
distance
,
2
)
distance_str
=
round
(
distance
,
2
)
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
replace
(
"${distance}"
,
"%s公里"
%
distance_str
).
\
replace
(
"${distance}"
,
"%s km"
%
distance_str
).
\
replace
(
"${speed}"
,
"%s 公里/秒"
%
round
(
self
.
earth
.
velocity
[
2
],
2
))
replace
(
"${acceleration}"
,
"%s"
%
acceleration_info
).
\
replace
(
"${speed}"
,
"%s km/s"
%
round
(
self
.
earth
.
velocity
[
2
],
2
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录