Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
51e688bc
宇宙模拟器
项目概览
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看板
提交
51e688bc
编写于
6月 29, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
b1ffd379
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
25 addition
and
13 deletion
+25
-13
sim_scenes/solar_system/solar_system_habitable_zone.py
sim_scenes/solar_system/solar_system_habitable_zone.py
+25
-13
未找到文件。
sim_scenes/solar_system/solar_system_habitable_zone.py
浏览文件 @
51e688bc
...
@@ -13,20 +13,21 @@ from sim_scenes.func import mayavi_run, ursina_run
...
@@ -13,20 +13,21 @@ from sim_scenes.func import mayavi_run, ursina_run
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
ursina
import
Vec3
from
ursina
import
Vec3
,
time
import
numpy
as
np
import
numpy
as
np
import
math
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# 目前认为 太阳系 的宜居带范围是从距离太阳0.95个天文单位 (约1.42亿千米)到 2.4个天文单位(约3.59亿千米)的范围为宜居带,
# 目前认为 太阳系 的宜居带范围是从距离太阳0.95个天文单位 (约1.42亿千米)到 2.4个天文单位(约3.59亿千米)的范围为宜居带,
# 其宽度约为2.17亿千米, 按照这个标准,太阳系的宜居带中只有三个大型天体,分别是地球、 月球 以及火星(1.52天文单位)。
# 其宽度约为2.17亿千米, 按照这个标准,太阳系的宜居带中只有三个大型天体,分别是地球、 月球 以及火星(1.52天文单位)。
sun
=
Sun
(
name
=
"太阳"
,
size_scale
=
0.5e2
)
# 太阳放大 80 倍,距离保持不变
sun
=
Sun
(
name
=
"太阳"
,
size_scale
=
0.5e2
)
# 太阳放大 80 倍,距离保持不变
earth
=
Earth
(
name
=
"地球"
,
size_scale
=
1.5e3
)
# 地球放大 1500 倍,距离保持不变
earth
=
Earth
(
name
=
"地球"
,
size_scale
=
1.5e3
)
# 地球放大 1500 倍,距离保持不变
moon_d
=
1
0000000
moon_d
=
2
0000000
moon
=
Moon
(
name
=
"月球"
,
size_scale
=
1
e2
,
moon
=
Moon
(
name
=
"月球"
,
size_scale
=
1
.5e3
,
init_position
=
[
moon_d
,
0
,
0
],
init_position
=
[
moon_d
,
0
,
AU
],
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
distance_scale
=
0.2
,
ignore_mass
=
True
,
gravity_only_for_earth
=
True
#
gravity_only_for_earth=True
)
)
bodies
=
[
bodies
=
[
sun
,
sun
,
...
@@ -49,7 +50,15 @@ if __name__ == '__main__':
...
@@ -49,7 +50,15 @@ if __name__ == '__main__':
def
on_ready
():
def
on_ready
():
# 月球就会跟着地球自转而转
# 月球就会跟着地球自转而转
moon
.
planet
.
parent
=
earth
.
planet
# moon.planet.parent = earth.planet
# # 让月亮围绕地球的北极旋转90度
# moon.planet.rotation_x = 90
# moon.planet.rotation_y = 0
#
# # 让月亮围绕地球的南极旋转90度
# moon.planet.rotation_z = -90
# moon.planet.position = Vec3(0, 0, 0)
pass
def
on_timer_changed
(
time_data
:
TimeData
):
def
on_timer_changed
(
time_data
:
TimeData
):
...
@@ -58,13 +67,16 @@ if __name__ == '__main__':
...
@@ -58,13 +67,16 @@ if __name__ == '__main__':
# earth.planet.rotation_y,
# earth.planet.rotation_y,
# earth.planet.rotation_z)
# earth.planet.rotation_z)
# 为了不让月球随着地球的周期旋转,则需要获取地球的旋转角度
# 为了不让月球随着地球的周期旋转,则需要获取地球的旋转角度
angle
=
earth
.
planet
.
rotation_y
#
angle = earth.planet.rotation_y
# TODO:根据旋转的角度对月球的位置进行计算,保证月球公转和地球自转的关系 365天=12月
#
#
TODO:根据旋转的角度对月球的位置进行计算,保证月球公转和地球自转的关系 365天=12月
# angle = np.array(angle * np.pi)
# angle = np.array(angle * np.pi)
#
angle
=
time_data
.
total_days
/
15
*
np
.
pi
# px = moon_d * UrsinaConfig.SCALE_FACTOR * np.cos(angle)
px
=
moon_d
*
np
.
cos
(
angle
)
# pz = moon_d * UrsinaConfig.SCALE_FACTOR * np.sin(angle)
pz
=
moon_d
*
np
.
sin
(
angle
)
# moon.planet.world_position = Vec3(0,0,0)
# moon.planet.world_position = Vec3(px,0,pz)
moon
.
position
=
[
earth
.
position
[
0
]
+
px
,
0
,
earth
.
position
[
2
]
+
pz
]
# moon.planet.position = Vec3(16 * math.sin(time.time() * 2 + 0.5), 16 * math.cos(time.time() * 2 + 0.5), 0)
pass
# 订阅事件后,上面2个函数功能才会起作用
# 订阅事件后,上面2个函数功能才会起作用
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录