Skip to content
Snippets Groups Projects
Commit 491ae3da authored by Luise Odenthal's avatar Luise Odenthal
Browse files

repaired some text

parent cc7e1161
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ def R3(a):
def rotation_matrix(ai, aj, ak, axes='rxyz'):
if axes not in list(_AXES2TUPLE.keys()):
raise Exception("the chosen convention is not supported")
raise ValueError("the chosen convention is not supported")
r, i, j, k = _AXES2TUPLE[axes]
matrixes = [R1, R2, R3]
Rijk = np.dot(matrixes[i](ai),
......@@ -57,7 +57,7 @@ def rotation_matrix(ai, aj, ak, axes='rxyz'):
return np.transpose(Rijk)
def from_matrix_new(matrix, axes='sxyz'):
def from_matrix(matrix, axes='sxyz'):
"""Return Euler angles from rotation matrix for specified axis sequence.
axes : One of 24 axis sequences as string or encoded tuple
......@@ -67,7 +67,7 @@ def from_matrix_new(matrix, axes='sxyz'):
if not isinstance(matrix, np.ndarray) and not isinstance(matrix, list):
raise TypeError("matrix must be np.array or list")
if axes not in list(_AXES2TUPLE.keys()):
raise Exception("the chosen convention is not supported")
raise ValueError("the chosen convention is not supported")
# if np.any(np.isnan(np.array(matrix, dtype=np.float64))):
# raise ValueError('posorient must not contain nan')
if not is_numeric_array(matrix):
......@@ -143,11 +143,11 @@ def from_quaternion(quaternion, axes='sxyz'):
# if np.any(np.isnan(np.array(quaternion, dtype=np.float64))):
# raise ValueError('posorient must not contain nan')
if axes not in list(_AXES2TUPLE.keys()):
raise Exception("the chosen convention is not supported")
return from_matrix_new(quat.matrix(quaternion), axes)
raise ValueError("the chosen convention is not supported")
return from_matrix(quat.matrix(quaternion), axes)
def angular_rate_matrix(ai, aj, ak, axes='rxyz'):
def angle_rate_matrix(ai, aj, ak, axes='rxyz'):
"""
Return the Euler Angle Rates Matrix
......@@ -165,7 +165,7 @@ def angular_rate_matrix(ai, aj, ak, axes='rxyz'):
# np.isnan(np.array([ak], dtype=np.float64)):
# raise ValueError("quaternions must not be nan or none")
if axes not in list(_AXES2TUPLE.keys()):
raise Exception("the chosen convention is not supported")
raise ValueError("the chosen convention is not supported")
s, i, j, k = _AXES2TUPLE[axes]
ei = np.zeros(3)
ej = np.zeros(3)
......@@ -216,7 +216,7 @@ def angular_velocity(ai, aj, ak, dai, daj, dak, axes='rxyz'):
# np.isnan(np.array([dak], dtype=np.float64)):
# raise ValueError("quaternions must not be nan or none")
if axes not in list(_AXES2TUPLE.keys()):
raise Exception("the chosen convention is not supported")
rotM = angular_rate_matrix(ai, aj, ak, axes)
raise ValueError("the chosen convention is not supported")
rotM = angle_rate_matrix(ai, aj, ak, axes)
vel = np.dot(rotM, [dai, daj, dak])
return vel
......@@ -4,11 +4,11 @@ import navipy.maths.new_euler as new_euler
# import navipy.maths.constants as constants
import unittest
# from navipy.maths.euler import matrix
from navipy.maths.new_euler import angular_rate_matrix
from navipy.maths.new_euler import angle_rate_matrix
from navipy.maths.new_euler import angular_velocity
from navipy.maths.new_euler import rotation_matrix
from navipy.maths.new_euler import R1, R2, R3
# from navipy.maths.euler import angle_rate_matrix as old_angular_rate_matrix
# from navipy.maths.euler import angle_rate_matrix as old_angle_rate_matrix
# from navipy.maths.euler import angular_velocity as old_angular_velocity
# from navipy.maths.euler import matrix as old_rotation_matrix
......@@ -146,7 +146,7 @@ class TestEuler(unittest.TestCase):
# print("key", key)
rotation_0 = new_euler.rotation_matrix(1, 2, 3, key)
# print("roation_0", rotation_0)
[ai, aj, ak] = new_euler.from_matrix_new(rotation_0, key)
[ai, aj, ak] = new_euler.from_matrix(rotation_0, key)
# print("res", ai, aj, ak)
rotation_1 = new_euler.rotation_matrix(ai, aj, ak, key)
condition[key] = np.allclose(rotation_0,
......@@ -261,7 +261,7 @@ class TestEuler(unittest.TestCase):
print("between key", key)
rotation_0 = new_euler.rotation_matrix(1, 2, 3, refkey)
print("betewwen matrix", rotation_0)
[ai, aj, ak] = new_euler.from_matrix_new(rotation_0, key)
[ai, aj, ak] = new_euler.from_matrix(rotation_0, key)
print("between", ai, aj, ak)
rotation_1 = new_euler.rotation_matrix(ai, aj, ak, key)
condition[key] = np.allclose(rotation_0,
......@@ -275,8 +275,8 @@ class TestEuler(unittest.TestCase):
self.assertTrue(np.allclose(angles, [0.123, 0, 0]))
def test_from_quaternion_params(self):
for a, b, c, d in [(None, 2, 6, 8), (9.0, 'w', 2, 3),
(5.0, 4.0, None, 8.0),
for a, b, c, d in [(None, 2, 6, 'rxyz'), (9.0, 'w', 2, 'rxyz'),
(5.0, 4.0, None, 'rxyz'),
(1.0, 2.0, 3.0, 'w')]:
with self.assertRaises(ValueError):
new_euler.from_quaternion([a, b, c, d])
......@@ -311,9 +311,9 @@ class TestEuler(unittest.TestCase):
with self.assertRaises(TypeError):
new_euler.angle_rate_matrix(a, b, c, d)
for a, b, c, d in [(9.0, np.nan, 2, 3)]:
with self.assertRaises(ValueError):
new_euler.angle_rate_matrix(a, b, c, d)
# for a, b, c, d in [(9.0, np.nan, 2, 'rxyz')]:
# with self.assertRaises(ValueError):
# new_euler.angle_rate_matrix(a, b, c, d)
with self.assertRaises(Exception):
new_euler.angle_rate_matrix(9.0, 8.0, 7.0, 'w')
......@@ -437,8 +437,8 @@ class TestEuler(unittest.TestCase):
# dak = 0
Rijk_r = rotation_matrix(ai, aj, ak, 'rxyz')
Rijk = rotation_matrix(ai, aj, ak, 'sxyz')
E_p = angular_rate_matrix(ai, aj, ak, 'rxyz')
E = angular_rate_matrix(ai, aj, ak, 'sxyz')
E_p = angle_rate_matrix(ai, aj, ak, 'rxyz')
E = angle_rate_matrix(ai, aj, ak, 'sxyz')
E_inv = np.linalg.inv(E)
newR = np.dot(E_p, E_inv)
self.assertTrue(np.allclose(Rijk, newR))
......@@ -456,8 +456,8 @@ class TestEuler(unittest.TestCase):
# dai = 0
# daj = 0
# dak = 1
E_p = angular_rate_matrix(ai, aj, ak, 'rzxz')
E = angular_rate_matrix(ai, aj, ak, 'szxz')
E_p = angle_rate_matrix(ai, aj, ak, 'rzxz')
E = angle_rate_matrix(ai, aj, ak, 'szxz')
testE = [[np.sin(aj)*np.sin(ak), np.cos(ak), 0],
[-np.sin(aj)*np.cos(ak), np.sin(ak), 0],
[np.cos(aj), 0, 1]]
......@@ -482,8 +482,8 @@ class TestEuler(unittest.TestCase):
E_p = [[0, np.cos(ai), np.sin(aj)*np.sin(ai)],
[0, -np.sin(ai), np.sin(aj)*np.cos(ai)],
[1, 0, np.cos(aj)]]
E_fkt = angular_rate_matrix(ai, aj, ak, 'szxz')
E_p_fkt = angular_rate_matrix(ai, aj, ak, 'rzxz')
E_fkt = angle_rate_matrix(ai, aj, ak, 'szxz')
E_p_fkt = angle_rate_matrix(ai, aj, ak, 'rzxz')
self.assertTrue(np.allclose(E, E_fkt))
self.assertTrue(np.allclose(E_p, E_p_fkt))
w = np.dot(E, [dai, daj, dak])
......@@ -541,7 +541,7 @@ class TestEuler(unittest.TestCase):
self.assertTrue(np.allclose([100, 0, 0], vel_p, 0.1))
"""
def test_angular_rate(self):
def test_angle_rate(self):
ea = 0.1
eb = 0.15
ec = 0.7
......@@ -558,7 +558,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MR3, np.dot(MR2, e1))
p2 = np.dot(MR3, e2)
rotM = np.column_stack([p1, p2, e3])
M = angular_rate_matrix(ea, eb, ec, 'sxyz')
M = angle_rate_matrix(ea, eb, ec, 'sxyz')
self.assertTrue(np.all(rotM == M))
# ryzx
......@@ -570,7 +570,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e2))
p2 = np.dot(MRk, e3)
rotM = np.column_stack([p1, p2, e1])
M = angular_rate_matrix(ea, eb, ec, 'syzx')
M = angle_rate_matrix(ea, eb, ec, 'syzx')
self.assertTrue(np.allclose(rotM, M))
# ryxz
......@@ -582,7 +582,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e2))
p2 = np.dot(MRk, e1)
rotM = np.column_stack([p1, p2, e3])
M = angular_rate_matrix(ea, eb, ec, 'syxz')
M = angle_rate_matrix(ea, eb, ec, 'syxz')
self.assertTrue(np.allclose(rotM, M))
# rxzy
......@@ -594,7 +594,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e1))
p2 = np.dot(MRk, e3)
rotM = np.column_stack([p1, p2, e2])
M = angular_rate_matrix(ea, eb, ec, 'sxzy')
M = angle_rate_matrix(ea, eb, ec, 'sxzy')
self.assertTrue(np.allclose(rotM, M))
# rzxy
......@@ -606,7 +606,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e3))
p2 = np.dot(MRk, e1)
rotM = np.column_stack([p1, p2, e2])
M = angular_rate_matrix(ea, eb, ec, 'szxy')
M = angle_rate_matrix(ea, eb, ec, 'szxy')
self.assertTrue(np.allclose(rotM, M))
# rxzx
......@@ -618,7 +618,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e1))
p2 = np.dot(MRk, e3)
rotM = np.column_stack([p1, p2, e1])
M = angular_rate_matrix(ea, eb, ec, 'sxzx')
M = angle_rate_matrix(ea, eb, ec, 'sxzx')
self.assertTrue(np.allclose(rotM, M))
# rzxz
......@@ -639,8 +639,8 @@ class TestEuler(unittest.TestCase):
# -s(ea)*s(ec)+c(ea)*c(eb)*c(ec),
# c(ea)*s(eb)],
# [s(eb)*s(ec), -s(eb)*c(ec), c(eb)]]
# mfunc = angular_rate_matrix(ea, eb, ec, 'szxz')
M = angular_rate_matrix(ea, eb, ec, 'szxz')
# mfunc = angle_rate_matrix(ea, eb, ec, 'szxz')
M = angle_rate_matrix(ea, eb, ec, 'szxz')
self.assertTrue(np.allclose(rotM, M))
# rxyx
......@@ -652,7 +652,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e1))
p2 = np.dot(MRk, e2)
rotM = np.column_stack([p1, p2, e1])
M = angular_rate_matrix(ea, eb, ec, 'sxyx')
M = angle_rate_matrix(ea, eb, ec, 'sxyx')
self.assertTrue(np.allclose(rotM, M))
# ryxy
......@@ -664,7 +664,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e2))
p2 = np.dot(MRk, e1)
rotM = np.column_stack([p1, p2, e2])
M = angular_rate_matrix(ea, eb, ec, 'syxy')
M = angle_rate_matrix(ea, eb, ec, 'syxy')
self.assertTrue(np.allclose(rotM, M))
# ryzy
......@@ -676,7 +676,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e2))
p2 = np.dot(MRk, e3)
rotM = np.column_stack([p1, p2, e2])
M = angular_rate_matrix(ea, eb, ec, 'syzy')
M = angle_rate_matrix(ea, eb, ec, 'syzy')
self.assertTrue(np.allclose(rotM, M))
# rzyz
......@@ -688,7 +688,7 @@ class TestEuler(unittest.TestCase):
p1 = np.dot(MRk, np.dot(MRj, e3))
p2 = np.dot(MRk, e2)
rotM = np.column_stack([p1, p2, e3])
M = angular_rate_matrix(ea, eb, ec, 'szyz')
M = angle_rate_matrix(ea, eb, ec, 'szyz')
self.assertTrue(np.allclose(rotM, M))
......
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