我尝试在python中实现以下关于X和Y点的公式
我尝试过以下方法def f(c):
"""This function computes the curvature of the leaf."""
tt = c
n = (tt[0]*tt[3] - tt[1]*tt[2])
d = (tt[0]**2 + tt[1]**2)
k = n/d
R = 1/k # Radius of Curvature
return R
有点不正确,因为它没有给我正确的结果。我想我在计算前两行的导数时犯了一些错误。我该怎么解决呢?在
以下是数据帧中的一些点:
^{pr2}$
在得到导数后,我使用以下代码将导数x_prim、x_prim、y_prim、y_prim_prim放入另一个数据帧中:d = pd.DataFrame({'x_prim': pts_x, 'y_prim': pts_y, 'x_prim_prim': pts_xx, 'y_prim_prim':pts_yy})
在数据帧中包含所有内容后,我将为数据帧的每一行调用函数,以使用以下代码获得该点的曲率:# Getting the curvature at each point
for i in range(len(d)):
temp = d.iloc[i]
c_temp = f(temp)
curv.append(c_temp)