def distance_curves(x, ys, q1):
"""
Distances to the curves.
:param x: x values of curves (they have to be sorted).
:param ys: y values of multiple curves sharing x values.
:param q1: a point to measure distance to.
:return:
"""
# convert curves into a series of startpoints and endpoints
xp = rolling_window(x, 2)
ysp = rolling_window(ys, 2)
r = np.nanmin(distance_line_segment(xp[:, 0], ysp[:, :, 0],
xp[:, 1], ysp[:, :, 1],
q1[0], q1[1]), axis=1)
return r
评论列表
文章目录