Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
thopri
PyNEMO
Commits
a1e57f44
Commit
a1e57f44
authored
5 years ago
by
James Harle
Browse files
Options
Download
Email Patches
Plain Diff
add in distance function to replace the depreciated mlab ones
parent
0e40f9b2
master
IMMERSE
github/fork/vleguenn/feature/update_README
0.2.0
0.1.0
1 merge request
!47
Py nemo3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
pynemo/gui/selection_editor.py
pynemo/gui/selection_editor.py
+1
-1
pynemo/utils/nemo_bdy_lib.py
pynemo/utils/nemo_bdy_lib.py
+25
-0
No files found.
pynemo/gui/selection_editor.py
View file @
a1e57f44
...
...
@@ -9,7 +9,7 @@ import numpy as np
from
matplotlib.lines
import
Line2D
from
matplotlib.patches
import
Polygon
from
matplotlib.artist
import
Artist
from
matplotlib.mla
b
import
dist_point_to_segment
from
pynemo.utils.nemo_bdy_li
b
import
dist_point_to_segment
from
matplotlib.widgets
import
RectangleSelector
...
...
This diff is collapsed.
Click to expand it.
pynemo/utils/nemo_bdy_lib.py
View file @
a1e57f44
...
...
@@ -127,4 +127,29 @@ def bdy_transport():
Keyword arguments:
"""
raise
NotImplementedError
def
dist
(
self
,
x
,
y
):
"""
Return the distance between two points.
"""
d
=
x
-
y
return
np
.
sqrt
(
np
.
dot
(
d
,
d
))
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
"""
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
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment