Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
0b202405
宇宙模拟器
项目概览
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看板
提交
0b202405
编写于
12月 09, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
68e733fd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
5 deletion
+43
-5
common/func.py
common/func.py
+21
-2
sim_scenes/solar_system/solar_system_reality_2.py
sim_scenes/solar_system/solar_system_reality_2.py
+22
-3
未找到文件。
common/func.py
浏览文件 @
0b202405
...
@@ -15,6 +15,24 @@ import math
...
@@ -15,6 +15,24 @@ import math
import
time
import
time
def
au_to_ly
(
au
):
"""
将天文单位转换为光年
:param au: 天文单位
:return: 光年
"""
return
au
/
63241.0770847
def
ly_to_au
(
ly
):
"""
将光年转换为天文单位
:param ly: 光年
:return: 天文单位
"""
return
ly
*
63241.0770847
def
get_dominant_colors
(
infile
,
resize
=
(
20
,
20
)):
def
get_dominant_colors
(
infile
,
resize
=
(
20
,
20
)):
"""
"""
获取图片的主要颜色
获取图片的主要颜色
...
@@ -106,7 +124,7 @@ def wait_for(secs):
...
@@ -106,7 +124,7 @@ def wait_for(secs):
wait
-=
1
wait
-=
1
def
calculate_acceleration
(
current_v
,
distance
,
t
):
def
calculate_acceleration
(
current_v
,
distance
,
t
):
"""
"""
计算加速度,使得当前物体到达目的距离需要的加速度
计算加速度,使得当前物体到达目的距离需要的加速度
@param current_v: 物体当前速度(km/s)
@param current_v: 物体当前速度(km/s)
...
@@ -117,9 +135,10 @@ def calculate_acceleration(current_v , distance, t):
...
@@ -117,9 +135,10 @@ def calculate_acceleration(current_v , distance, t):
current_v
=
current_v
*
1000
# km/s -> m/s
current_v
=
current_v
*
1000
# km/s -> m/s
distance
=
distance
*
1000
# km -> m
distance
=
distance
*
1000
# km -> m
acceleration
=
2
*
(
distance
-
current_v
*
t
)
/
(
t
**
2
)
acceleration
=
2
*
(
distance
-
current_v
*
t
)
/
(
t
**
2
)
acceleration
=
acceleration
/
1000
# m/s^2 -> km/s^2
acceleration
=
acceleration
/
1000
# m/s^2 -> km/s^2
return
acceleration
return
acceleration
def
calculate_distance
(
pos1
,
pos2
=
[
0
,
0
,
0
]):
def
calculate_distance
(
pos1
,
pos2
=
[
0
,
0
,
0
]):
"""
"""
计算两点间的距离
计算两点间的距离
...
...
sim_scenes/solar_system/solar_system_reality_2.py
浏览文件 @
0b202405
...
@@ -13,7 +13,7 @@ from bodies import Sun, Mercury, Venus, Earth, Mars, Asteroids, Jupiter, Saturn,
...
@@ -13,7 +13,7 @@ from bodies import Sun, Mercury, Venus, Earth, Mars, Asteroids, Jupiter, Saturn,
from
common.celestial_data_service
import
get_body_posvel
,
recalc_moon_position
,
calc_solar_acceleration
,
\
from
common.celestial_data_service
import
get_body_posvel
,
recalc_moon_position
,
calc_solar_acceleration
,
\
set_solar_system_celestial_position
,
set_earth_rotation
,
get_reality_orbit_points
set_solar_system_celestial_position
,
set_earth_rotation
,
get_reality_orbit_points
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HOUR
,
AU
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_HOUR
,
AU
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
,
create_text_panel
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.func
import
ext_fun_for_method
from
simulators.func
import
ext_fun_for_method
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.body_timer
import
TimeData
...
@@ -156,7 +156,24 @@ class SolarSystemRealitySim(UniverseSimScenes):
...
@@ -156,7 +156,24 @@ class SolarSystemRealitySim(UniverseSimScenes):
delattr
(
self
.
earth
.
planet
,
"rotspeed"
)
delattr
(
self
.
earth
.
planet
,
"rotspeed"
)
# 设置后,可以调整鼠标键盘的控制速度
# 设置后,可以调整鼠标键盘的控制速度
application
.
time_scale
=
1
application
.
time_scale
=
5
self
.
text_panel
=
create_text_panel
(
font
=
"fonts/DroidSansFallback.ttf"
,
font_scale
=
1.3
)
self
.
text_panel
.
parent
.
scale_y
/=
6
self
.
text_panel
.
scale_y
*=
6
def
update_text_panel
(
self
):
"""
更新文字信息面板
@param d_sun:
@return:
"""
from
ursina
import
distance
d_sun
=
distance
(
self
.
sun
.
planet
.
position
,
camera
.
position
)
d_sun
=
d_sun
/
UrsinaConfig
.
SCALE_FACTOR
/
AU
panel_text
=
"当前日距:%s AU"
%
"{:.2f}"
.
format
(
d_sun
)
# .rjust(6, "0")
self
.
text_panel
.
text
=
panel_text
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
"""
"""
...
@@ -171,6 +188,7 @@ class SolarSystemRealitySim(UniverseSimScenes):
...
@@ -171,6 +188,7 @@ class SolarSystemRealitySim(UniverseSimScenes):
set_earth_rotation
(
self
.
earth
,
dt
)
set_earth_rotation
(
self
.
earth
,
dt
)
# 显示时钟
# 显示时钟
# self.show_clock(dt)
# self.show_clock(dt)
self
.
update_text_panel
()
def
bind_events
(
self
):
def
bind_events
(
self
):
# 运行中,每时每刻都会触发 on_timer_changed
# 运行中,每时每刻都会触发 on_timer_changed
...
@@ -373,7 +391,8 @@ class SolarSystemRealitySim(UniverseSimScenes):
...
@@ -373,7 +391,8 @@ class SolarSystemRealitySim(UniverseSimScenes):
UrsinaConfig
.
run_speed_factor
=
0.01
UrsinaConfig
.
run_speed_factor
=
0.01
body
.
planet
.
origin_update
=
body
.
planet
.
update
body
.
planet
.
origin_update
=
body
.
planet
.
update
size_scale
,
scale_x
=
self
.
body_scale_dict
[
body
]
size_scale
,
scale_x
=
self
.
body_scale_dict
[
body
]
scale_inc
=
(
scale_x
-
scale_x
/
size_scale
)
/
200.0
scale_inc
=
(
scale_x
-
scale_x
/
size_scale
)
/
200.0
# scale_inc = (scale_x / size_scale) / 10.0
# scale_inc = (scale_x / size_scale) / 10.0
def
update_scale
():
def
update_scale
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录