Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Commits
abcce8ac
Commit
abcce8ac
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
fixed calculation for angle differences
parent
260c1964
No related branches found
No related tags found
1 merge request
!6
Develop
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
skais/ais/ais_trajectory.py
+6
-4
6 additions, 4 deletions
skais/ais/ais_trajectory.py
skais/tests/ais/test_ais_trajectory.py
+14
-14
14 additions, 14 deletions
skais/tests/ais/test_ais_trajectory.py
with
20 additions
and
18 deletions
skais/ais/ais_trajectory.py
+
6
−
4
View file @
abcce8ac
...
@@ -141,16 +141,18 @@ def compute_position_dist_std(dat, radius):
...
@@ -141,16 +141,18 @@ def compute_position_dist_std(dat, radius):
def
angle_between_three_points
(
p1
,
p2
,
p3
):
def
angle_between_three_points
(
p1
,
p2
,
p3
):
alpha
=
bearing
(
p2
,
p1
)
alpha
=
bearing
(
p2
,
p1
)
beta
=
bearing
(
p2
,
p3
)
beta
=
bearing
(
p2
,
p3
)
result
=
alpha
-
beta
return
alpha
-
beta
if
result
>
180
:
return
180
-
result
else
:
return
result
def
compute_point_angles
(
dat
):
def
compute_point_angles
(
dat
):
angles
=
np
.
zeros
(
dat
.
shape
[
0
])
angles
=
np
.
zeros
(
dat
.
shape
[
0
])
p1
=
(
dat
[
0
][
0
],
dat
[
0
][
1
])
p1
=
(
dat
[
0
][
0
],
dat
[
0
][
1
])
p2
=
(
dat
[
1
][
0
],
dat
[
1
][
1
])
p2
=
(
dat
[
1
][
0
],
dat
[
1
][
1
])
angles
[
0
]
=
bearing
(
p
2
,
p
1
)
angles
[
0
]
=
bearing
(
p
1
,
p
2
)
for
i
in
range
(
1
,
dat
.
shape
[
0
]
-
1
):
for
i
in
range
(
1
,
dat
.
shape
[
0
]
-
1
):
p1
=
(
dat
[
i
-
1
][
0
],
dat
[
i
-
1
][
1
])
p1
=
(
dat
[
i
-
1
][
0
],
dat
[
i
-
1
][
1
])
p2
=
(
dat
[
i
][
0
],
dat
[
i
][
1
])
p2
=
(
dat
[
i
][
0
],
dat
[
i
][
1
])
...
...
This diff is collapsed.
Click to expand it.
skais/tests/ais/test_ais_trajectory.py
+
14
−
14
View file @
abcce8ac
...
@@ -356,32 +356,32 @@ class TestAISTrajectory(unittest.TestCase):
...
@@ -356,32 +356,32 @@ class TestAISTrajectory(unittest.TestCase):
self
.
assertAlmostEqual
(
result
,
expected
)
self
.
assertAlmostEqual
(
result
,
expected
)
def
test_angle_between_three_points_1
(
self
):
def
test_angle_between_three_points_1
(
self
):
p1
=
(
0
,
0
)
p1
=
(
0
,
-
1
0
)
p2
=
(
0
,
1
0
)
p2
=
(
0
,
0
)
p3
=
(
10
,
1
0
)
p3
=
(
10
,
0
)
self
.
assertEqual
(
90
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
))
self
.
assert
Almost
Equal
(
90
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
)
,
places
=
3
)
def
test_angle_between_three_points_2
(
self
):
def
test_angle_between_three_points_2
(
self
):
p1
=
(
0
,
0
)
p1
=
(
0
,
-
1
0
)
p2
=
(
0
,
1
0
)
p2
=
(
0
,
0
)
p3
=
(
-
10
,
-
1
0
)
p3
=
(
-
10
,
0
)
self
.
assertEqual
(
-
90
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
))
self
.
assert
Almost
Equal
(
-
90
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
)
,
places
=
3
)
def
test_angle_between_three_points_3
(
self
):
def
test_angle_between_three_points_3
(
self
):
p1
=
(
0
,
0
)
p1
=
(
0
,
-
1
0
)
p2
=
(
0
,
1
0
)
p2
=
(
0
,
0
)
p3
=
(
10
,
2
0
)
p3
=
(
10
,
1
0
)
self
.
assert
Equal
(
42.814167
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
))
self
.
assert
AlmostEqual
(
180
-
44.56139
,
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
)
,
places
=
3
)
def
test_angle_between_three_points_4
(
self
):
def
test_angle_between_three_points_4
(
self
):
p1
=
(
0
,
0
)
p1
=
(
0
,
0
)
p2
=
(
0
0
,
10
)
p2
=
(
0
,
10
)
p3
=
(
0
,
0
)
p3
=
(
0
,
0
)
self
.
assertEqual
(
18
0
,
abs
(
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
)))
self
.
assert
Almost
Equal
(
0
,
abs
(
angle_between_three_points
.
py_func
(
p1
,
p2
,
p3
))
,
places
=
3
)
# def test_compute_position_angle_std(self):
# def test_compute_position_angle_std(self):
...
...
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