Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
7fd5314f
宇宙模拟器
项目概览
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看板
提交
7fd5314f
编写于
6月 10, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
93a4e893
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
31 addition
and
17 deletion
+31
-17
sim_scenes/science/earth_seasons.py
sim_scenes/science/earth_seasons.py
+4
-2
sim_scenes/science/lagrangian_points_2.py
sim_scenes/science/lagrangian_points_2.py
+8
-6
simulators/ursina/entities/body_timer.py
simulators/ursina/entities/body_timer.py
+19
-9
未找到文件。
sim_scenes/science/earth_seasons.py
浏览文件 @
7fd5314f
...
...
@@ -6,12 +6,13 @@
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
ursina
import
camera
from
bodies
import
Sun
,
Earth
from
common.consts
import
SECONDS_PER_
WEEK
,
SECONDS_PER_
DAY
,
AU
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
ursina_run
,
camera_look_at
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
ursina
import
camera
def
create_earth
(
name
,
text_color
,
position
):
...
...
@@ -101,6 +102,7 @@ if __name__ == '__main__':
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
on_timer_changed
)
# 设置计时器的最小时间单位为天
BodyTimer
().
min_unit
=
BodyTimer
.
MIN_UNIT_DAYS
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
...
...
sim_scenes/science/lagrangian_points_2.py
浏览文件 @
7fd5314f
...
...
@@ -6,14 +6,15 @@
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
import
math
from
bodies
import
Earth
,
Moon
from
objs
import
Satellite
,
Satellite2
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
common.consts
import
SECONDS_PER_HOUR
from
objs
import
Satellite
from
sim_scenes.func
import
ursina_run
,
camera_look_at
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.body_timer
import
TimeData
,
BodyTimer
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_mesh
import
create_connecting_lines
import
math
# 月球绕地球的半径
R
=
363104
...
...
@@ -73,7 +74,7 @@ if __name__ == '__main__':
if
hasattr
(
earth
,
"lines"
):
for
line
in
earth
.
lines
:
destroy
(
line
)
if
int
(
time_data
.
total_hours
)
%
3
==
0
:
if
int
(
time_data
.
total_hours
)
%
8
==
0
:
# 创建连接线(将卫星列表用线条连接起来)
earth
.
lines
=
create_connecting_lines
([
[
satelliteL2
,
satelliteL3
],
...
...
@@ -88,7 +89,8 @@ if __name__ == '__main__':
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
on_timer_changed
)
# 设置计时器的最小时间单位为分钟
BodyTimer
().
min_unit
=
BodyTimer
.
MIN_UNIT_MINUTES
bodies
=
[
earth
,
moon
,
satelliteL1
,
satelliteL2
,
satelliteL3
,
satelliteL4
,
satelliteL5
]
# 使用 ursina 查看的运行效果
...
...
simulators/ursina/entities/body_timer.py
浏览文件 @
7fd5314f
...
...
@@ -33,11 +33,19 @@ class TimeData:
self
.
seconds
=
int
(
seconds
)
self
.
min_unit
=
min_unit
if
days
>
1
or
years
>=
1
or
self
.
min_unit
in
[
BodyTimer
.
MIN_UNIT_DAYS
,
BodyTimer
.
MIN_UNIT_YEARS
]:
s_days
=
str
(
days
).
rjust
(
3
,
" "
)
if
self
.
min_unit
in
[
BodyTimer
.
MIN_UNIT_YEARS
]:
self
.
time_text
=
f
'
{
self
.
years
}
年'
elif
days
>=
20
or
years
>=
1
or
self
.
min_unit
in
[
BodyTimer
.
MIN_UNIT_DAYS
]:
elif
self
.
min_unit
in
[
BodyTimer
.
MIN_UNIT_DAYS
]:
self
.
time_text
=
f
'
{
self
.
years
}
年
{
s_days
}
天'
elif
self
.
min_unit
in
[
BodyTimer
.
MIN_UNIT_MINUTES
]:
self
.
time_text
=
f
'
{
self
.
days
}
天
{
self
.
hours
:
02
d
}
:
{
self
.
minutes
:
02
d
}
'
elif
self
.
min_unit
in
[
BodyTimer
.
MIN_UNIT_HOURS
]:
self
.
time_text
=
f
'
{
self
.
days
}
天
{
self
.
hours
:
02
d
}
时'
else
:
if
days
>
1
or
years
>=
1
:
if
days
>=
20
or
years
>=
1
:
self
.
time_text
=
f
'
{
self
.
years
}
年
{
s_days
}
天'
else
:
self
.
time_text
=
f
'
{
self
.
days
}
天
{
self
.
hours
:
02
d
}
:
{
self
.
minutes
:
02
d
}
:
{
self
.
seconds
:
02
d
}
'
...
...
@@ -65,6 +73,8 @@ class BodyTimer(Singleton):
最后通过公式: 时间 = 距离 / 速度, 从而得到天体运行了多长时间
"""
MIN_UNIT_SECONDS
=
"seconds"
MIN_UNIT_MINUTES
=
"minutes"
MIN_UNIT_HOURS
=
"hours"
MIN_UNIT_DAYS
=
"days"
MIN_UNIT_YEARS
=
"years"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录