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

dist_point_to_segement deprecated in matplotlib 3.1.1 #18

Open
raphaeldussin opened this issue Jul 23, 2019 · 1 comment
Open

dist_point_to_segement deprecated in matplotlib 3.1.1 #18

raphaeldussin opened this issue Jul 23, 2019 · 1 comment

Comments

@raphaeldussin
Copy link
Contributor

function is :

def dist_point_to_segment(p, s0, s1):
    """
    Get the distance of a point to a segment.

      *p*, *s0*, *s1* are *xy* sequences

    This algorithm from
    http://geomalgorithms.com/a02-_lines.html
    """
    p = np.asarray(p, float)
    s0 = np.asarray(s0, float)
    s1 = np.asarray(s1, float)
    v = s1 - s0
    w = p - s0

    c1 = np.dot(w, v)
    if c1 <= 0:
        return dist(p, s0)

    c2 = np.dot(v, v)
    if c2 <= c1:
        return dist(p, s1)

    b = c1 / c2
    pb = s0 + b * v
    return dist(p, pb)

do we know the equivalent? or should we just add this piece of code to pyroms?
@kshedstrom what do you think?

@kshedstrom
Copy link
Collaborator

The matplotlib deprecated section implies that there are numpy equivalents. See for example https://stackoverflow.com/questions/39840030/distance-between-point-and-a-line-from-two-points. Can you make it work with np.cross?

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

2 participants