Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
99064a26
宇宙模拟器
项目概览
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看板
提交
99064a26
编写于
8月 04, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
2718abd2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
4 deletion
+47
-4
sim_scenes/tri_bodies/water_drop_01.py
sim_scenes/tri_bodies/water_drop_01.py
+47
-4
未找到文件。
sim_scenes/tri_bodies/water_drop_01.py
浏览文件 @
99064a26
...
@@ -56,9 +56,9 @@ if __name__ == '__main__':
...
@@ -56,9 +56,9 @@ if __name__ == '__main__':
num_x
=
10
num_x
=
10
num_y
=
10
num_y
=
10
num_z
=
10
num_z
=
10
num_x
=
4
num_x
=
2
num_y
=
4
num_y
=
2
num_z
=
4
num_z
=
2
x_offset
=
-
(
num_x
)
/
2
*
d
x_offset
=
-
(
num_x
)
/
2
*
d
y_offset
=
-
(
num_y
)
/
2
*
(
d
/
2
)
y_offset
=
-
(
num_y
)
/
2
*
(
d
/
2
)
...
@@ -89,6 +89,47 @@ if __name__ == '__main__':
...
@@ -89,6 +89,47 @@ if __name__ == '__main__':
WATER_RANGE
=
2e6
WATER_RANGE
=
2e6
# def calc_velocity(current_pos, to_pos, velocity_fact):
# """
# 计算一个物体,从物体当前位置(三维坐标系)到达指定位置(三维坐标系)的矢量速度 x,y,z 分量的速度( * 速度因子 velocity_fact)
# @param current_pos: 物体当前位置(三维坐标系)
# @param to_pos: 指定位置(三维坐标系)
# @param velocity_fact: 速度因子
# @return: 矢量速度 x,y,z 分量的速度
# """
# velocity = [0, 0, 0]
# # TODO:在这里实现代码
#
# return velocity
import
math
def
calc_velocity
(
current_pos
,
to_pos
,
velocity_fact
):
"""
Calculate the velocity vector components (x, y, z) for an object to move from its current position to a specified position,
considering the velocity factor.
@param current_pos: Current position of the object (in a three-dimensional coordinate system)
@param to_pos: Specified position (in a three-dimensional coordinate system)
@param velocity_fact: Velocity factor
@return: Velocity vector components (x, y, z)
"""
velocity
=
[
0
,
0
,
0
]
# Calculate the differences in each dimension
diff_x
=
to_pos
[
0
]
-
current_pos
[
0
]
diff_y
=
to_pos
[
1
]
-
current_pos
[
1
]
diff_z
=
to_pos
[
2
]
-
current_pos
[
2
]
# Calculate the total distance
total_distance
=
math
.
sqrt
(
diff_x
**
2
+
diff_y
**
2
+
diff_z
**
2
)
# Calculate the proportions of velocity in each dimension
velocity
[
0
]
=
diff_x
/
total_distance
velocity
[
1
]
=
diff_y
/
total_distance
velocity
[
2
]
=
diff_z
/
total_distance
# Adjust the velocity using the velocity factor
velocity
[
0
]
*=
velocity_fact
velocity
[
1
]
*=
velocity_fact
velocity
[
2
]
*=
velocity_fact
return
velocity
def
on_timer_changed
(
time_data
:
TimeData
):
def
on_timer_changed
(
time_data
:
TimeData
):
if
time_data
.
total_days
>
0.2
:
if
time_data
.
total_days
>
0.2
:
...
@@ -99,7 +140,9 @@ if __name__ == '__main__':
...
@@ -99,7 +140,9 @@ if __name__ == '__main__':
water_drop
.
planet
.
rotation_z
=
90
water_drop
.
planet
.
rotation_z
=
90
water_drop
.
velocity
=
[
-
WATER_SPEED
,
0
,
0
]
water_drop
.
velocity
=
[
-
WATER_SPEED
,
0
,
0
]
else
:
else
:
water_drop
.
acceleration
=
[
-
9.8e-4
,
0
,
0
]
velocity
=
calc_velocity
(
water_drop
.
position
,
ship_list
[
0
].
position
,
1
)
# water_drop.acceleration = [-9.8e-4, 0, 0]
water_drop
.
velocity
=
velocity
camera_look_at
(
water_drop
,
rotation_z
=
0
)
camera_look_at
(
water_drop
,
rotation_z
=
0
)
# camera.y += UrsinaConfig.SCALE_FACTOR * 100
# camera.y += UrsinaConfig.SCALE_FACTOR * 100
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录