Python 用什么替换matplotlib不推荐使用的line2d_seg_dist函数?

Python 用什么替换matplotlib不推荐使用的line2d_seg_dist函数?,python,matplotlib,Python,Matplotlib,我想知道是否有什么东西可以取代不推荐使用的函数。文档页面上没有提到它,我也不完全确定如何替换它。您只需将函数放入代码中即可: def line2d_seg_dist(p1, p2, p0): """distance(s) from line defined by p1 - p2 to point(s) p0 p0[0] = x(s) p0[1] = y(s) intersection point p = p1 + u*(p2-p1) and inter

我想知道是否有什么东西可以取代不推荐使用的函数。文档页面上没有提到它,我也不完全确定如何替换它。

您只需将函数放入代码中即可:

def line2d_seg_dist(p1, p2, p0):
    """distance(s) from line defined by p1 - p2 to point(s) p0

    p0[0] = x(s)
    p0[1] = y(s)

    intersection point p = p1 + u*(p2-p1)
    and intersection point lies within segment if u is between 0 and 1
    """

    x21 = p2[0] - p1[0]
    y21 = p2[1] - p1[1]
    x01 = np.asarray(p0[0]) - p1[0]
    y01 = np.asarray(p0[1]) - p1[1]

    u = (x01*x21 + y01*y21) / (x21**2 + y21**2)
    u = np.clip(u, 0, 1)
    d = np.hypot(x01 - u*x21, y01 - u*y21)

    return d

您只需将函数放入代码中:

def line2d_seg_dist(p1, p2, p0):
    """distance(s) from line defined by p1 - p2 to point(s) p0

    p0[0] = x(s)
    p0[1] = y(s)

    intersection point p = p1 + u*(p2-p1)
    and intersection point lies within segment if u is between 0 and 1
    """

    x21 = p2[0] - p1[0]
    y21 = p2[1] - p1[1]
    x01 = np.asarray(p0[0]) - p1[0]
    y01 = np.asarray(p0[1]) - p1[1]

    u = (x01*x21 + y01*y21) / (x21**2 + y21**2)
    u = np.clip(u, 0, 1)
    d = np.hypot(x01 - u*x21, y01 - u*y21)

    return d

根据
3.1.0
API变更文档,没有替换,建议在需要时向供应商提供上述功能,即按照@ImportanceOFBeingErnest所说的做

Multiple internal functions that were exposed as part of the public API of mpl_toolkits.mplot3d are deprecated,

mpl_toolkits.mplot3d.art3d

mpl_toolkits.mplot3d.art3d.norm_angle()
mpl_toolkits.mplot3d.art3d.norm_text_angle()
mpl_toolkits.mplot3d.art3d.path_to_3d_segment()
mpl_toolkits.mplot3d.art3d.paths_to_3d_segments()
mpl_toolkits.mplot3d.art3d.path_to_3d_segment_with_codes()
mpl_toolkits.mplot3d.art3d.paths_to_3d_segments_with_codes()
mpl_toolkits.mplot3d.art3d.get_patch_verts()
mpl_toolkits.mplot3d.art3d.get_colors()
mpl_toolkits.mplot3d.art3d.zalpha()
mpl_toolkits.mplot3d.proj3d

mpl_toolkits.mplot3d.proj3d.line2d()
mpl_toolkits.mplot3d.proj3d.line2d_dist()
mpl_toolkits.mplot3d.proj3d.line2d_seg_dist()
mpl_toolkits.mplot3d.proj3d.mod()
mpl_toolkits.mplot3d.proj3d.proj_transform_vec()
mpl_toolkits.mplot3d.proj3d.proj_transform_vec_clip()
mpl_toolkits.mplot3d.proj3d.vec_pad_ones()
mpl_toolkits.mplot3d.proj3d.proj_trans_clip_points()
If your project relies on these functions, consider vendoring them.

根据
3.1.0
API变更文档,没有替换,建议在需要时向供应商提供上述功能,即按照@ImportanceOFBeingErnest所说的做

Multiple internal functions that were exposed as part of the public API of mpl_toolkits.mplot3d are deprecated,

mpl_toolkits.mplot3d.art3d

mpl_toolkits.mplot3d.art3d.norm_angle()
mpl_toolkits.mplot3d.art3d.norm_text_angle()
mpl_toolkits.mplot3d.art3d.path_to_3d_segment()
mpl_toolkits.mplot3d.art3d.paths_to_3d_segments()
mpl_toolkits.mplot3d.art3d.path_to_3d_segment_with_codes()
mpl_toolkits.mplot3d.art3d.paths_to_3d_segments_with_codes()
mpl_toolkits.mplot3d.art3d.get_patch_verts()
mpl_toolkits.mplot3d.art3d.get_colors()
mpl_toolkits.mplot3d.art3d.zalpha()
mpl_toolkits.mplot3d.proj3d

mpl_toolkits.mplot3d.proj3d.line2d()
mpl_toolkits.mplot3d.proj3d.line2d_dist()
mpl_toolkits.mplot3d.proj3d.line2d_seg_dist()
mpl_toolkits.mplot3d.proj3d.mod()
mpl_toolkits.mplot3d.proj3d.proj_transform_vec()
mpl_toolkits.mplot3d.proj3d.proj_transform_vec_clip()
mpl_toolkits.mplot3d.proj3d.vec_pad_ones()
mpl_toolkits.mplot3d.proj3d.proj_trans_clip_points()
If your project relies on these functions, consider vendoring them.

是的,“照@ImportanceOfBeingErnest所说的去做”是对所有事情的一般回答,当然除了42个。什么是“出售”?出售是你自己复制你的项目使用的第三方软件包的行为。这些副本通常放在每个项目中,然后保存在项目存储库中。是的,“照@ImportanceOfBeingErnest所说的去做”是对所有事情的一般回答,当然除了42个。什么是“自动售货机”?自动售货机是你自己制作项目使用的第三方软件包副本的行为。这些副本通常放在每个项目中,然后保存在项目存储库中。