Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
659169d9
宇宙模拟器
项目概览
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看板
提交
659169d9
编写于
4月 04, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
e33c3ba0
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
40 addition
and
13 deletion
+40
-13
sim_scenes/earth/__init__.py
sim_scenes/earth/__init__.py
+0
-0
sim_scenes/earth/free_fall_of_ball.py
sim_scenes/earth/free_fall_of_ball.py
+28
-0
sim_scenes/solar_system/earth_moon6.py
sim_scenes/solar_system/earth_moon6.py
+6
-8
simulators/ursina/entities/body_trail.py
simulators/ursina/entities/body_trail.py
+6
-5
未找到文件。
sim_scenes/earth/__init__.py
0 → 100644
浏览文件 @
659169d9
sim_scenes/earth/free_fall_of_ball.py
0 → 100644
浏览文件 @
659169d9
# -*- coding:utf-8 -*-
# title :地月场景模拟
# description :地月场景模拟
# author :Python超人
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Moon
,
Earth
,
Body
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
sim_scenes.func
import
mayavi_run
,
ursina_run
from
bodies.body
import
AU
if
__name__
==
'__main__'
:
"""
地球、6个月球
"""
# 地球在中心位置
e
=
Earth
(
init_position
=
[
0
,
0
,
0
],
size_scale
=
1
,
texture
=
"earth_hd.jpg"
,
init_velocity
=
[
0
,
0
,
0
])
bodies
=
[
e
,
Moon
(
name
=
'小球'
,
mass
=
4.4e18
,
init_position
=
[
0
,
e
.
raduis
+
500
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 球在地球上面500km
]
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
60
,
position
=
(
0
,
e
.
raduis
+
500
,
-
4500
),
show_trail
=
True
,
view_closely
=
0.001
)
sim_scenes/solar_system/earth_moon6.py
浏览文件 @
659169d9
...
...
@@ -15,18 +15,16 @@ if __name__ == '__main__':
"""
地球、6个月球
"""
# 地球的Y方向初始速度
EARTH_INIT_VELOCITY
=
0
# 地球在中心位置
e
=
Earth
(
init_position
=
[
0
,
0
,
0
],
texture
=
"earth_hd.jpg"
,
init_velocity
=
[
0
,
0
,
0
])
bodies
=
[
e
,
Moon
(
init_position
=
[
e
.
diameter
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
前
面
Moon
(
init_position
=
[
-
e
.
diameter
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
后
面
Moon
(
init_position
=
[
0
,
e
.
diameter
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
左
面
Moon
(
init_position
=
[
0
,
-
e
.
diameter
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
右
面
Moon
(
init_position
=
[
0
,
0
,
e
.
diameter
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
上
面
Moon
(
init_position
=
[
0
,
0
,
-
e
.
diameter
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
下
面
Moon
(
init_position
=
[
e
.
diameter
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
右
面
Moon
(
init_position
=
[
-
e
.
diameter
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
左
面
Moon
(
init_position
=
[
0
,
e
.
diameter
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
上
面
Moon
(
init_position
=
[
0
,
-
e
.
diameter
,
0
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
下
面
Moon
(
init_position
=
[
0
,
0
,
e
.
diameter
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
前
面
Moon
(
init_position
=
[
0
,
0
,
-
e
.
diameter
],
init_velocity
=
[
0
,
0
,
0
]),
# 月球在地球
后
面
]
# 使用 ursina 查看的运行效果
...
...
simulators/ursina/entities/body_trail.py
浏览文件 @
659169d9
...
...
@@ -38,12 +38,13 @@ class BodyTrail(Entity):
if
self
.
hovered
:
if
key
==
'left mouse down'
:
# print(key, self)
if
hasattr
(
self
,
"entity_infos"
):
self
.
show_infos
()
def
show_infos
(
self
):
if
not
hasattr
(
self
,
"entity_infos"
):
return
if
not
hasattr
(
self
,
"origin_alpha"
):
self
.
origin_color
=
self
.
color
#
self.origin_color = self.color
self
.
origin_alpha
=
self
.
alpha
if
len
(
self
.
children
)
>
0
:
...
...
@@ -52,7 +53,7 @@ class BodyTrail(Entity):
# self.color = self.origin_color
self
.
alpha
=
self
.
origin_alpha
return
self
.
alpha
=
0.
2
self
.
alpha
=
0.
3
# self.color = get_inverse_color(self.origin_color)
vel_info
,
vel_direction
,
vel_position
=
self
.
entity_infos
[
"velocity"
]
...
...
@@ -66,7 +67,7 @@ class BodyTrail(Entity):
v_line
.
enabled
=
False
a_arrow
,
a_line
,
a_text
=
create_arrow_line
((
0
,
0
,
0
),
tuple
(
acc_direction
),
parent
=
self
,
label
=
acc_info
,
color
=
color
.
yellow
,
alpha
=
0.8
,
arrow_scale
=
0.5
)
label
=
acc_info
,
color
=
color
.
green
,
alpha
=
0.8
,
arrow_scale
=
0.5
)
if
str
(
acc_info
).
startswith
(
"0.00"
):
a_text
.
parent
=
self
a_arrow
.
enabled
=
False
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录