离散点求曲率
第一步:离散点拟合函数
第二步:求一阶及二阶导,并带入求曲率公式。
import numpy as np
# x = 离散点x-axis坐标
# y = 离散点y-axis坐标
# x_target = 为拟合的函数采样点(这里是采样点的x-axis值)
# 第一步拟合函数
poly = np.polyfit(x, y, 3) # 拟合n次函数(这里为3次)
poly = np.poly1d(poly)
y_target = poly(x_target)
# 第二步求导
x_t = np.gradient(x_target) # x' 一阶导
xx_t = np.gradient(x_t) # x'' 二阶导
y_t = np.gradient(y_target) # y' 一阶导
yy_t = np.gradient(y_t) # y'' 二阶导
curvature_val = np.abs(xx_t * y_t - x_t * yy_t) / (x_t * x_t + y_t * y_t) ** 1.5 # 求曲率公式
该博客介绍了如何通过数学方法计算离散点的曲率。首先,使用多项式拟合离散点,然后求出一阶和二阶导数。通过曲率公式,结合导数计算得到曲率值,从而理解数据的局部弯曲特性。
2529

被折叠的 条评论
为什么被折叠?



