Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
d661e2df
宇宙模拟器
项目概览
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看板
提交
d661e2df
编写于
6月 17, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
044d4c1c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
74 addition
and
1 deletion
+74
-1
bodies/saturn.py
bodies/saturn.py
+6
-1
sim_scenes/solar_system/solarsystem_planets_size.py
sim_scenes/solar_system/solarsystem_planets_size.py
+68
-0
未找到文件。
bodies/saturn.py
浏览文件 @
d661e2df
...
@@ -43,15 +43,20 @@ class Saturn(Body):
...
@@ -43,15 +43,20 @@ class Saturn(Body):
"trail_color"
:
trail_color
,
"trail_color"
:
trail_color
,
"show_name"
:
show_name
"show_name"
:
show_name
}
}
self
.
__has_rings
=
True
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
def
show_rings
(
self
,
value
):
self
.
__has_rings
=
value
return
self
@
property
@
property
def
has_rings
(
self
):
def
has_rings
(
self
):
"""
"""
土星带光环的天体
土星带光环的天体
@return:
@return:
"""
"""
return
True
return
self
.
__has_rings
@
property
@
property
def
rings_color
(
self
):
def
rings_color
(
self
):
...
...
sim_scenes/solar_system/solarsystem_planets_size.py
0 → 100644
浏览文件 @
d661e2df
# -*- coding:utf-8 -*-
# title :太阳系行星大小比较
# description :太阳系行星大小比较
# author :Python超人
# date :2023-06-17
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.ursina_event
import
UrsinaEvent
# 地球和月球之间的距离常量,距地距离约: 363104 至 405696 km,平均距离 384000 km
E_M_DISTANCE
=
405696
earth
=
Earth
(
"地球"
,
init_position
=
[
0
,
0
,
0
])
moon
=
Moon
(
"月球"
,
init_position
=
[
E_M_DISTANCE
,
0
,
0
])
bodies
=
[
earth
,
moon
,
Mercury
(
name
=
"水星"
),
Venus
(
name
=
"金星"
),
Mars
(
name
=
"火星"
),
Jupiter
(
name
=
"木星"
),
Saturn
(
name
=
"土星"
).
show_rings
(
False
),
Uranus
(
name
=
"天王星"
),
Neptune
(
name
=
"海王星"
),
Pluto
(
name
=
"冥王星"
)
]
# 从第三个星球(水星)开始
index
=
2
last_total_hours
=
0
if
__name__
==
'__main__'
:
last_diameter
=
earth
.
diameter
/
2
plant_positions
=
[]
for
i
,
body
in
enumerate
(
bodies
):
body
.
ignore_mass
=
True
body
.
init_velocity
=
[
0
,
0
,
0
]
if
i
>=
2
:
# 从第三个星球(水星)开始
plant_positions
.
append
([(
body
.
diameter
/
2
)
+
last_diameter
,
0
,
0
])
last_diameter
+=
body
.
diameter
def
on_timer_changed
(
time_data
:
TimeData
):
global
index
,
last_total_hours
if
index
>=
len
(
bodies
):
return
total_hours
=
int
(
time_data
.
total_hours
)
if
total_hours
%
3
==
0
and
last_total_hours
!=
total_hours
:
last_total_hours
=
total_hours
bodies
[
index
].
init_position
=
plant_positions
[
index
-
2
]
index
+=
1
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
on_timer_changed
)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_HOUR
,
position
=
(
E_M_DISTANCE
/
2
,
0
,
-
E_M_DISTANCE
*
1
),
view_closely
=
True
,
timer_enabled
=
True
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录