Skip to content
Snippets Groups Projects
Commit a89ab2ce authored by Malte Nyhuis's avatar Malte Nyhuis
Browse files

cleanup and test-implementations

parent fa2366bf
No related branches found
No related tags found
No related merge requests found
...@@ -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
......
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment