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
a89ab2ce
Commit
a89ab2ce
authored
3 years ago
by
Malte Nyhuis
Browse files
Options
Downloads
Patches
Plain Diff
cleanup and test-implementations
parent
fa2366bf
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
+1
-11
1 addition, 11 deletions
ntrfc/utils/math/vectorcalc.py
tests/test_ntrfc_math.py
+21
-11
21 additions, 11 deletions
tests/test_ntrfc_math.py
with
22 additions
and
22 deletions
ntrfc/utils/math/vectorcalc.py
+
1
−
11
View file @
a89ab2ce
...
@@ -103,16 +103,6 @@ def RotFromTwoVecs(vec1, vec2):
...
@@ -103,16 +103,6 @@ def RotFromTwoVecs(vec1, vec2):
return
rotation_matrix
return
rotation_matrix
def
radiusFromPt
(
pts
,
sigma
):
pts
=
np
.
abs
(
pts
)
if
pts
[
1
]
>
0
:
teta
=
np
.
arctan
(
pts
[
2
]
/
pts
[
1
])
else
:
teta
=
0
r
=
sigma
[
1
]
*
sigma
[
2
]
/
((
np
.
sin
(
teta
)
*
sigma
[
2
])
**
2
+
(
np
.
cos
(
teta
)
*
sigma
[
1
])
**
2
)
**
.
5
return
r
def
vecAbs
(
vec
):
def
vecAbs
(
vec
):
"""
"""
tested method to calculate the absolute value of a vector
tested method to calculate the absolute value of a vector
...
@@ -137,7 +127,7 @@ def posVec(vec):
...
@@ -137,7 +127,7 @@ def posVec(vec):
def
findNearest
(
array
,
point
):
def
findNearest
(
array
,
point
):
array
=
np
.
asarray
(
array
)
array
=
np
.
asarray
(
array
)
idx
=
(
np
.
abs
(
array
-
point
)).
argmin
()
idx
=
np
.
array
([
vecAbs
(
i
)
for
i
in
(
np
.
abs
(
array
-
point
))
])
.
argmin
()
return
idx
return
idx
...
...
This diff is collapsed.
Click to expand it.
tests/test_ntrfc_math.py
+
21
−
11
View file @
a89ab2ce
...
@@ -100,10 +100,6 @@ def test_RotFromTwoVecs():
...
@@ -100,10 +100,6 @@ def test_RotFromTwoVecs():
Rcontrol
=
Rz
(
np
.
pi
/
2
)
Rcontrol
=
Rz
(
np
.
pi
/
2
)
assert
all
(
np
.
isclose
(
Rab
,
Rcontrol
).
flatten
())
assert
all
(
np
.
isclose
(
Rab
,
Rcontrol
).
flatten
())
def
test_radiusFromPt
():
from
ntrfc.utils.math.vectorcalc
import
radiusFromPt
a
=
radiusFromPt
def
test_posVec
():
def
test_posVec
():
import
numpy
as
np
import
numpy
as
np
...
@@ -114,23 +110,37 @@ def test_posVec():
...
@@ -114,23 +110,37 @@ def test_posVec():
b
=
posVec
(
a
)
b
=
posVec
(
a
)
blength
=
vecAbs
(
b
)
blength
=
vecAbs
(
b
)
assert
alength
==
blength
assert
alength
==
blength
assert
np
.
equal
(
-
1
*
a
,
b
)
assert
all
(
np
.
isclose
(
-
1
*
a
,
b
).
flatten
()
)
def
test_findNearest
():
def
test_findNearest
():
from
ntrfc.utils.math.vectorcalc
import
findNearest
from
ntrfc.utils.math.vectorcalc
import
findNearest
a
=
findNearest
import
pyvista
as
pv
import
numpy
as
np
res
=
100
line
=
pv
.
Line
(
resolution
=
res
)
point
=
np
.
array
([
0
,
0
,
0
])
near
=
findNearest
(
line
.
points
,
point
)
assert
near
==
int
(
res
/
2
)
def
test_eulersFromRPG
():
def
test_eulersFromRPG
():
from
ntrfc.utils.math.vectorcalc
import
eulersFromRPG
from
ntrfc.utils.math.vectorcalc
import
eulersFromRPG
,
RotFromTwoVecs
,
vecAngle
a
=
eulersFromRPG
import
numpy
as
np
a
=
np
.
array
([
1
,
0
,
0
])
b
=
np
.
array
([
0
,
1
,
0
])
cangle
=
vecAngle
(
a
,
b
)
R
=
RotFromTwoVecs
(
a
,
b
)
angle
=
eulersFromRPG
(
R
)
assert
angle
[
0
]
==
cangle
def
test_randomOrthMat
():
def
test_randomOrthMat
():
from
ntrfc.utils.math.vectorcalc
import
randomOrthMat
from
ntrfc.utils.math.vectorcalc
import
randomOrthMat
a
=
randomOrthMat
import
numpy
as
np
o
=
randomOrthMat
()
dot_o
=
np
.
dot
(
o
,
o
.
T
)
assert
all
(
np
.
isclose
(
dot_o
,
np
.
identity
(
3
)).
flatten
())
def
test_minDists
():
def
test_minDists
():
from
ntrfc.utils.math.vectorcalc
import
minDists
from
ntrfc.utils.math.vectorcalc
import
minDists
...
...
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