Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'mpl_toolkits.mplot3d.proj3d' has no attribute 'line2d_seg_dist' #109

Open
fangwancong opened this issue Jul 19, 2021 · 0 comments

Comments

@fangwancong
Copy link

I got an error "AttributeError: module 'mpl_toolkits.mplot3d.proj3d' has no attribute 'line2d_seg_dist'" when running on the matplotlib 3.4.2, it is a deprecated method. Is there an update for this? I added the line2d_seg_dist method to the pick_info.py file to replace it, and it is feasible for the time being.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant