Skip to content

Commit

Permalink
Add Tests for Quaternion methods log and logarithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayitzin committed Nov 6, 2024
1 parent aeeac7d commit 6c269ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_quaternions.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ def test_exp(self):
np.testing.assert_allclose(ahrs.Quaternion([0, 0, 1, 0]).exp, [np.cos(1), 0, np.sin(1), 0])
np.testing.assert_allclose(ahrs.Quaternion([0, 0, 0, 1]).exp, [np.cos(1), 0, 0, np.sin(1)])

def test_logarithm(self):
np.testing.assert_allclose(ahrs.Quaternion([1, 0, 0, 0]).logarithm, [0, 0, 0, 0])
np.testing.assert_allclose(ahrs.Quaternion([0, 1, 0, 0]).logarithm, [0, np.pi/2, 0, 0])
np.testing.assert_allclose(ahrs.Quaternion([0, 0, 1, 0]).logarithm, [0, 0, np.pi/2, 0])
np.testing.assert_allclose(ahrs.Quaternion([0, 0, 0, 1]).logarithm, [0, 0, 0, np.pi/2])
np.testing.assert_allclose(ahrs.Quaternion([1, 1, 0, 0]).logarithm, [0, np.pi/4, 0, 0])
np.testing.assert_allclose(ahrs.Quaternion([1, 0, 1, 0]).logarithm, [0, 0, np.pi/4, 0])
np.testing.assert_allclose(ahrs.Quaternion([1, 0, 0, 1]).logarithm, [0, 0, 0, np.pi/4])

def test_log(self):
np.testing.assert_allclose(ahrs.Quaternion([1, 0, 0, 0]).log, [0, 0, 0, 0])
np.testing.assert_allclose(ahrs.Quaternion([0, 1, 0, 0]).log, [0, np.pi/2, 0, 0])
np.testing.assert_allclose(ahrs.Quaternion([0, 0, 1, 0]).log, [0, 0, np.pi/2, 0])
np.testing.assert_allclose(ahrs.Quaternion([0, 0, 0, 1]).log, [0, 0, 0, np.pi/2])
np.testing.assert_allclose(ahrs.Quaternion([1, 1, 0, 0]).log, [0, np.pi/4, 0, 0])
np.testing.assert_allclose(ahrs.Quaternion([1, 0, 1, 0]).log, [0, 0, np.pi/4, 0])
np.testing.assert_allclose(ahrs.Quaternion([1, 0, 0, 1]).log, [0, 0, 0, np.pi/4])

class TestQuaternionArray(unittest.TestCase):
def setUp(self) -> None:
self.Q0 = ahrs.QuaternionArray()
Expand Down

0 comments on commit 6c269ab

Please sign in to comment.