def test_multiplication(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar ab = a*b self.assertAlmostEqual(ab.x,a.x*b.x,places=6) self.assertAlmostEqual(ab.y,a.y*b.y,places=6) self.assertAlmostEqual(ab.z,a.z*b.z,places=6) ac = a * c self.assertAlmostEqual(ac.x,a.x*c,places=6) self.assertAlmostEqual(ac.y,a.y*c,places=6) self.assertAlmostEqual(ac.z,a.z*c,places=6)
def test_subtraction(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar ab = a-b self.assertEqual(ab.x,a.x-b.x) self.assertEqual(ab.y,a.y-b.y) self.assertEqual(ab.z,a.z-b.z) ac = a - c self.assertAlmostEqual(ac.x,a.x-c,places=6) self.assertAlmostEqual(ac.y,a.y-c,places=6) self.assertAlmostEqual(ac.z,a.z-c,places=6)
def test_division(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar if self._data_scalar != 0 else random.randint(1,100) ab = a/b self.assertAlmostEqual(ab.x,a.x/b.x,places=6) self.assertAlmostEqual(ab.y,a.y/b.y,places=6) self.assertAlmostEqual(ab.z,a.z/b.z,places=6) ac = a / c self.assertAlmostEqual(ac.x,a.x/c,places=6) self.assertAlmostEqual(ac.y,a.y/c,places=6) self.assertAlmostEqual(ac.z,a.z/c,places=6)
def test_addition(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar ab = a+b self.assertEqual(ab.x,a.x+b.x) self.assertEqual(ab.y,a.y+b.y) self.assertEqual(ab.z,a.z+b.z) ac = a + c self.assertAlmostEqual(ac.x,a.x+c,places=6) self.assertAlmostEqual(ac.y,a.y+c,places=6) self.assertAlmostEqual(ac.z,a.z+c,places=6)
def test_multiplication(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar ab = a * b self.assertAlmostEqual(ab.x, a.x * b.x, places=6) self.assertAlmostEqual(ab.y, a.y * b.y, places=6) self.assertAlmostEqual(ab.z, a.z * b.z, places=6) ac = a * c self.assertAlmostEqual(ac.x, a.x * c, places=6) self.assertAlmostEqual(ac.y, a.y * c, places=6) self.assertAlmostEqual(ac.z, a.z * c, places=6)
def test_subtraction(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar ab = a - b self.assertEqual(ab.x, a.x - b.x) self.assertEqual(ab.y, a.y - b.y) self.assertEqual(ab.z, a.z - b.z) ac = a - c self.assertAlmostEqual(ac.x, a.x - c, places=6) self.assertAlmostEqual(ac.y, a.y - c, places=6) self.assertAlmostEqual(ac.z, a.z - c, places=6)
def test_addition(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar ab = a + b self.assertEqual(ab.x, a.x + b.x) self.assertEqual(ab.y, a.y + b.y) self.assertEqual(ab.z, a.z + b.z) ac = a + c self.assertAlmostEqual(ac.x, a.x + c, places=6) self.assertAlmostEqual(ac.y, a.y + c, places=6) self.assertAlmostEqual(ac.z, a.z + c, places=6)
def test_division(self): a = vec3(*self._data_x) b = vec3(*self._data_y) c = self._data_scalar if self._data_scalar != 0 else random.randint( 1, 100) ab = a / b self.assertAlmostEqual(ab.x, a.x / b.x, places=6) self.assertAlmostEqual(ab.y, a.y / b.y, places=6) self.assertAlmostEqual(ab.z, a.z / b.z, places=6) ac = a / c self.assertAlmostEqual(ac.x, a.x / c, places=6) self.assertAlmostEqual(ac.y, a.y / c, places=6) self.assertAlmostEqual(ac.z, a.z / c, places=6)