Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NTRfC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFD - Institut für Turbomaschinen und Fluid-Dynamik
tools
NTRfC
Commits
c23d0f86
Commit
c23d0f86
authored
3 years ago
by
Malte Nyhuis
Browse files
Options
Downloads
Patches
Plain Diff
implement line_intersection
parent
0e68a038
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ntrfc/utils/math/vectorcalc.py
+18
-1
18 additions, 1 deletion
ntrfc/utils/math/vectorcalc.py
tests/test_ntrfc_math.py
+9
-0
9 additions, 0 deletions
tests/test_ntrfc_math.py
with
27 additions
and
1 deletion
ntrfc/utils/math/vectorcalc.py
+
18
−
1
View file @
c23d0f86
...
...
@@ -11,7 +11,7 @@ from scipy.spatial.distance import squareform, pdist
import
sys
import
math
as
m
import
scipy
def
calc_largedistant_idx
(
x_koords
,
y_koords
):
"""
...
...
@@ -231,3 +231,20 @@ def lineseg_dist(p, a, b):
return
np
.
hypot
(
h
,
np
.
linalg
.
norm
(
c
))
def
line_intersection
(
point_a1
,
point_a2
,
point_b1
,
point_b2
):
def
det_2d
(
a
,
b
):
return
a
[
0
]
*
b
[
1
]
-
a
[
1
]
*
b
[
0
]
xdiff
=
(
point_a1
[
0
]
-
point_a2
[
0
],
point_b1
[
0
]
-
point_b2
[
0
])
ydiff
=
(
point_a1
[
1
]
-
point_a2
[
1
],
point_b1
[
1
]
-
point_b2
[
1
])
div
=
det_2d
(
xdiff
,
ydiff
)
if
div
==
0
:
return
None
d
=
(
det_2d
(
point_a1
,
point_a2
),
det_2d
(
point_b1
,
point_b2
))
x
=
det_2d
(
d
,
xdiff
)
/
div
y
=
det_2d
(
d
,
ydiff
)
/
div
return
x
,
y
This diff is collapsed.
Click to expand it.
tests/test_ntrfc_math.py
+
9
−
0
View file @
c23d0f86
...
...
@@ -166,3 +166,12 @@ def test_vecAngle():
b
=
np
.
array
([
0
,
1
,
0
])
angle
=
vecAngle
(
a
,
b
)
assert
angle
==
np
.
pi
/
2
def
test_line_intersection
():
import
numpy
as
np
from
ntrfc.utils.math.vectorcalc
import
line_intersection
intersect
=
line_intersection
((
-
1
,
0
),(
1
,
0
),
(
0
,
-
1
),(
0
,
1
))
assert
all
(
intersect
==
np
.
array
([
0
,
0
]))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment