コード例 #1
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_left_scalar_division(self):
        a = pyrot.Quaternion(1, -2, 3, 4)
        b = 2

        c = a / b
        self.assertAlmostEqual(
            c, pyrot.Quaternion(1. / 2, -2. / 2, 3. / 2, 4. / 2))
コード例 #2
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_division(self):
        a = pyrot.Quaternion(1, -2, 3, 4)
        b = pyrot.Quaternion(-6, 2, 1, 2)

        c = a / b
        self.assertAlmostEqual(c * b, a)
コード例 #3
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_right_scalar_multiplication(self):
        a = pyrot.Quaternion(1, -2, 3, 4)
        b = 6

        c = b * a
        self.assertEqual(c, pyrot.Quaternion(6, -12, 18, 24))
コード例 #4
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_left_float_scalar_multiplication(self):
        a = pyrot.Quaternion(1, -2, 3, 4)
        b = 6.0

        c = a * b
        self.assertEqual(c, pyrot.Quaternion(6, -12, 18, 24))
コード例 #5
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
 def test_init(self):
     s = pyrot.Quaternion(1, 2, 3, 4)
     self.assertIsInstance(s, pyrot.Quaternion)
コード例 #6
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_norm(self):
        a = pyrot.Quaternion(1, -2, 3, 4)

        b = a.norm()
        self.assertAlmostEqual(b, 5.47722557505)
コード例 #7
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_right_scalar_sub(self):
        a = 3
        b = pyrot.Quaternion(1, 2, 3, 4)

        c = a - b
        self.assertEqual(c, pyrot.Quaternion(2, -2, -3, -4))
コード例 #8
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_scalar_add(self):
        a = 6
        b = pyrot.Quaternion(-6, 2, 1, 2)

        c = a + b
        self.assertEqual(c, pyrot.Quaternion(0, 2, 1, 2))
コード例 #9
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_sub(self):
        a = pyrot.Quaternion(-6, 2, 1, 2)
        b = pyrot.Quaternion(1, 2, 3, 4)

        c = a - b
        self.assertEqual(c, pyrot.Quaternion(-7, 0, -2, -2))
コード例 #10
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_bool_false(self):
        a = pyrot.Quaternion(0, 0, 0, 0)

        self.assertFalse(a)
コード例 #11
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_add(self):
        a = pyrot.Quaternion(-6, 2, 1, 2)
        b = pyrot.Quaternion(1, 2, 3, 4)

        c = a + b
        self.assertEqual(c, pyrot.Quaternion(-5, 4, 4, 6))
コード例 #12
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_bool_true(self):
        a = pyrot.Quaternion(1, -2, 3, 4)

        self.assertTrue(a)
コード例 #13
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_le(self):
        a = pyrot.Quaternion(1, -2, 3, 4)
        b = pyrot.Quaternion(-6, 2, 1, 2)

        with self.assertRaises(TypeError):
            (a <= b)
コード例 #14
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_inverse(self):
        a = pyrot.Quaternion(1, -2, 3, 4)
        b = a.inverse()

        c = a * b
        self.assertAlmostEqual(c, pyrot.Quaternion(1, 0, 0, 0))
コード例 #15
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_right_scalar_division(self):
        a = 2
        b = pyrot.Quaternion(1, -2, 3, 4)

        c = a / b
        self.assertAlmostEqual(c * b, a)
コード例 #16
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_left_scalar_sub(self):
        a = pyrot.Quaternion(1, 2, 3, 4)
        b = 3

        c = a - b
        self.assertEqual(c, pyrot.Quaternion(-2, 2, 3, 4))
コード例 #17
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_conjugation(self):
        a = pyrot.Quaternion(1, -2, 3, 4)

        b = a.conjugate()
        self.assertEqual(b, pyrot.Quaternion(1, 2, -3, -4))
コード例 #18
0
ファイル: test_quaternions.py プロジェクト: serycjon/pyrot
    def test_addition_stays_quaternion(self):
        a = pyrot.Quaternion(0, 0, 0, 0)
        b = pyrot.Quaternion(1, 2, 3, 4)

        c = a + b
        self.assertIsInstance(c, pyrot.Quaternion)