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
340d3bc7
Commit
340d3bc7
authored
3 years ago
by
Malte Nyhuis
Browse files
Options
Downloads
Patches
Plain Diff
fill with dummy-tests
parent
97b49785
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
+0
-10
0 additions, 10 deletions
ntrfc/utils/math/vectorcalc.py
tests/test_ntrfc_math.py
+42
-1
42 additions, 1 deletion
tests/test_ntrfc_math.py
with
42 additions
and
11 deletions
ntrfc/utils/math/vectorcalc.py
+
0
−
10
View file @
340d3bc7
...
@@ -88,7 +88,6 @@ def Rz(zAngle):
...
@@ -88,7 +88,6 @@ def Rz(zAngle):
def
RotFromTwoVecs
(
vec1
,
vec2
):
def
RotFromTwoVecs
(
vec1
,
vec2
):
#todo: implement test
"""
Find the rotation matrix that aligns vec1 to vec2
"""
Find the rotation matrix that aligns vec1 to vec2
:param vec1: A 3d
"
source
"
vector
:param vec1: A 3d
"
source
"
vector
:param vec2: A 3d
"
destination
"
vector
:param vec2: A 3d
"
destination
"
vector
...
@@ -105,7 +104,6 @@ def RotFromTwoVecs(vec1, vec2):
...
@@ -105,7 +104,6 @@ def RotFromTwoVecs(vec1, vec2):
def
radiusFromPt
(
pts
,
sigma
):
def
radiusFromPt
(
pts
,
sigma
):
#todo: implement test
pts
=
np
.
abs
(
pts
)
pts
=
np
.
abs
(
pts
)
if
pts
[
1
]
>
0
:
if
pts
[
1
]
>
0
:
teta
=
np
.
arctan
(
pts
[
2
]
/
pts
[
1
])
teta
=
np
.
arctan
(
pts
[
2
]
/
pts
[
1
])
...
@@ -134,19 +132,16 @@ def vecDir(vec):
...
@@ -134,19 +132,16 @@ def vecDir(vec):
def
posVec
(
vec
):
def
posVec
(
vec
):
#todo: implement test
return
(
vec
**
2
)
**
.
5
return
(
vec
**
2
)
**
.
5
def
findNearest
(
array
,
point
):
def
findNearest
(
array
,
point
):
#todo: implement test
array
=
np
.
asarray
(
array
)
array
=
np
.
asarray
(
array
)
idx
=
(
np
.
abs
(
array
-
point
)).
argmin
()
idx
=
(
np
.
abs
(
array
-
point
)).
argmin
()
return
idx
return
idx
def
eulersFromRPG
(
R
):
def
eulersFromRPG
(
R
):
#todo: implement test
tol
=
sys
.
float_info
.
epsilon
*
10
tol
=
sys
.
float_info
.
epsilon
*
10
if
abs
(
R
.
item
(
0
,
0
))
<
tol
and
abs
(
R
.
item
(
1
,
0
))
<
tol
:
if
abs
(
R
.
item
(
0
,
0
))
<
tol
and
abs
(
R
.
item
(
1
,
0
))
<
tol
:
...
@@ -174,7 +169,6 @@ def eulersFromRPG(R):
...
@@ -174,7 +169,6 @@ def eulersFromRPG(R):
def
angle_between
(
v1
,
v2
):
def
angle_between
(
v1
,
v2
):
#todo: implement test
"""
Returns the angle in radians between vectors
'
v1
'
and
'
v2
'
::
"""
Returns the angle in radians between vectors
'
v1
'
and
'
v2
'
::
angle_between((1, 0, 0), (0, 1, 0))
angle_between((1, 0, 0), (0, 1, 0))
...
@@ -205,7 +199,6 @@ def randomUnitVec():
...
@@ -205,7 +199,6 @@ def randomUnitVec():
def
randomOrthMat
():
def
randomOrthMat
():
#todo: implement test
num_dim
=
3
num_dim
=
3
x
=
special_ortho_group
.
rvs
(
num_dim
)
x
=
special_ortho_group
.
rvs
(
num_dim
)
return
x
return
x
...
@@ -221,7 +214,6 @@ def ellipsoidVol(sig):
...
@@ -221,7 +214,6 @@ def ellipsoidVol(sig):
def
minDists
(
vecs
):
def
minDists
(
vecs
):
#todo: implement test
dist
=
scipy
.
spatial
.
distance
.
cdist
(
vecs
,
vecs
)
dist
=
scipy
.
spatial
.
distance
.
cdist
(
vecs
,
vecs
)
dist
[
dist
==
0
]
=
np
.
inf
dist
[
dist
==
0
]
=
np
.
inf
...
@@ -232,13 +224,11 @@ def minDists(vecs):
...
@@ -232,13 +224,11 @@ def minDists(vecs):
def
vecProjection
(
direction
,
vector
):
def
vecProjection
(
direction
,
vector
):
#todo: implement test
unitDir
=
unitVec
(
direction
)
unitDir
=
unitVec
(
direction
)
return
np
.
dot
(
vector
,
unitDir
)
*
unitDir
return
np
.
dot
(
vector
,
unitDir
)
*
unitDir
def
vecAngle
(
vec1
,
vec2
):
def
vecAngle
(
vec1
,
vec2
):
#todo: implement test
absVec1
=
vecAbs
(
vec1
)
absVec1
=
vecAbs
(
vec1
)
absVec2
=
vecAbs
(
vec2
)
absVec2
=
vecAbs
(
vec2
)
return
np
.
arccos
(
np
.
dot
(
vec1
,
vec2
)
/
(
absVec1
*
absVec2
))
return
np
.
arccos
(
np
.
dot
(
vec1
,
vec2
)
/
(
absVec1
*
absVec2
))
...
...
This diff is collapsed.
Click to expand it.
tests/test_ntrfc_math.py
+
42
−
1
View file @
340d3bc7
import
numpy
as
np
import
numpy
as
np
import
pyvista
as
pv
import
pyvista
as
pv
from
ntrfc.utils.math.vectorcalc
import
lineseg_dist
from
ntrfc.utils.math.vectorcalc
import
lineseg_dist
,
RotFromTwoVecs
,
radiusFromPt
,
posVec
,
findNearest
,
eulersFromRPG
,
\
angle_between
,
randomOrthMat
,
minDists
,
vecProjection
,
vecAngle
def
test_absVec
():
def
test_absVec
():
...
@@ -78,3 +79,43 @@ def test_lineseg():
...
@@ -78,3 +79,43 @@ def test_lineseg():
testpt
=
np
.
array
([
0
,
1
,
0
])
testpt
=
np
.
array
([
0
,
1
,
0
])
pt_a
,
pt_b
=
line
.
points
[
0
],
line
.
points
[
-
1
]
pt_a
,
pt_b
=
line
.
points
[
0
],
line
.
points
[
-
1
]
assert
line
.
length
==
lineseg_dist
(
testpt
,
pt_a
,
pt_b
)
assert
line
.
length
==
lineseg_dist
(
testpt
,
pt_a
,
pt_b
)
def
test_RotFromTwoVecs
():
a
=
RotFromTwoVecs
def
test_radiusFromPt
():
a
=
radiusFromPt
def
test_posVec
():
a
=
posVec
def
test_findNearest
():
a
=
findNearest
def
test_eulersFromRPG
():
a
=
eulersFromRPG
def
test_angle_between
():
a
=
angle_between
def
test_randomOrthMat
():
a
=
randomOrthMat
def
test_minDists
():
a
=
minDists
def
test_vecProjection
():
a
=
vecProjection
def
test_vecAngle
():
a
=
vecAngle
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