1 Star 1 Fork 2

木子/PythonAutomatedDriving

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
curvature.py 666 Bytes
一键复制 编辑 原始数据 按行查看 历史
木子 提交于 3年前 . Update curvature
"""
计算曲率半径
"""
import numpy as np
def calculate_curvature(points: np.ndarray) -> float:
"""
曲率半径计算函数 \n
ref: https://github.com/Pjer-zhang/PJCurvature \n
:param points: 三个点的坐标
:return: 曲率半径
"""
x = points[:, 0]
y = points[:, 1]
t_a = np.linalg.norm([x[1] - x[0], y[1] - y[0]])
t_b = np.linalg.norm([x[2] - x[1], y[2] - y[1]])
m = np.array([[1, -t_a, t_a**2], [1, 0, 0], [1, t_b, t_b**2]])
a = np.matmul(np.linalg.inv(m), x)
b = np.matmul(np.linalg.inv(m), y)
kappa = 2 * (a[2] * b[1] - b[2] * a[1]) / (a[1] ** 2.0 + b[1] ** 2.0) ** 1.5
return kappa
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/muzing/PythonAutomatedDriving.git
git@gitee.com:muzing/PythonAutomatedDriving.git
muzing
PythonAutomatedDriving
PythonAutomatedDriving
main

搜索帮助