def test_inplace_sub(self): vec1 = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec2 = Vector3R(0.1529024479612, 0.983987651234, 0.1339887631011) vec1 -= vec2 self._check_approximate_each_value(vec1, 0.3241234856402 - vec2[0], 0.712532522433 - vec2[1], 0.2428385977825 - vec2[2])
def check_equality(self): vec1 = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec2 = Vector3R(0.1529024479612, 0.983987651234, 0.1339887631011) self.assertEqual(vec1 == vec1, True) self.assertEqual(vec1 != vec1, False) self.assertEqual(vec1 == vec2, False) self.assertEqual(vec1 != vec2, True)
def test_apply_rotate_eular(self): vec = Vector3R(2.3241234856402, 0.712532522433, 0.2428385977825) vec.applyRotateEuler(0.6070696824721713, 1.860040373113793, 0.6360120983116064) self._check_approximate_each_value(vec, -1.262214606971851, 1.5020586145520496, -1.4556295411260831)
def test_apply_boost_to_vector3R(self): vec1 = Vector4R(0.3241234856402, 0.712532522433, 0.2428385977825, 1.0389887631011) vec2 = Vector3R(0.1529024479612, 0.683987651234, 0.1339887631011) vec1.applyBoostTo(vec2) self._check_approximate_each_value(vec1, 1.0539417783464062, 0.8364361913339782, 0.7971042789464847, 1.1475658301206095)
def test_apply_boost_to_vector3R_inverse(self): vec1 = Vector4R(0.3241234856402, 0.712532522433, 0.2428385977825, 1.0389887631011) vec2 = Vector3R(0.1529024479612, 0.683987651234, 0.1339887631011) vec1.applyBoostTo(vec2, True) self._check_approximate_each_value(vec1, -0.12865682140904047, 0.6949578563565814, 0.16422079452874308, 1.0235880432245175)
def test_default_constructor(self): vec = Vector3R() self.assertIsInstance(vec, Vector3R, 'Failure: Not an instance of Vector3R')
def test_sub(self): vec1 = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec2 = Vector3R(0.1529024479612, 0.983987651234, 0.1339887631011) self._check_approximate_each_value(vec1 - vec2, 0.171221037679, -0.271455128801, 0.1088498346814)
def test_add(self): vec1 = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec2 = Vector3R(0.1529024479612, 0.983987651234, 0.1339887631011) self._check_approximate_each_value(vec1 + vec2, 0.4770259336014, 1.696520173667, 0.3768273608836)
def test_divide(self): vec = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) self._check_approximate_each_value(vec / 5.5, 0.058931542843672725, 0.1295513677150909, 0.04415247232409091)
def test_multiply_number_v2(self): vec = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) self._check_approximate_each_value(5.5 * vec, 1.7826791710210999, 3.9189288733815, 1.33561228780375)
def test_multiply(self): vec1 = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec2 = Vector3R(0.1529024479612, 0.983987651234, 0.1339887631011) self.assertAlmostEqual(vec1 * vec2, 0.7832201209228712) self.assertAlmostEqual(vec2 * vec1, 0.7832201209228712)
def test_d3mag(self): vec = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) self.assertAlmostEqual(vec.d3mag(), 0.81959088211208)
def test_dot(self): vec1 = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec2 = Vector3R(0.1529024479612, 0.983987651234, 0.1339887631011) self.assertAlmostEqual(vec1.dot(vec2), 0.1486778231883103)
def test_argument_constructor(self): vec = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) self.assertIsInstance(vec, Vector3R, 'Failure: Not an instance of Vector3R') self._check_approximate_each_value(vec, 0.3241234856402, 0.712532522433, 0.2428385977825)
def test_inplace_division(self): vec = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec /= 5.5 self._check_approximate_each_value(vec, 0.3241234856402 / 5.5, 0.712532522433 / 5.5, 0.2428385977825 / 5.5)
def test_inplace_multiply(self): vec = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec *= 5.5 self._check_approximate_each_value(vec, 0.3241234856402 * 5.5, 0.712532522433 * 5.5, 0.2428385977825 * 5.5)
def test_set_vector(self): vec = Vector3R() vec.set(0.3241234856402, 0.712532522433, 0.2428385977825) self._check_approximate_each_value(vec, 0.3241234856402, 0.712532522433, 0.2428385977825)
def test_set_two_arguments(self): vec = Vector3R() vec.set(1, 0.32447236432573858356) self.assertEqual(vec[1], 0.32447236432573858356)
def test_get(self): vec = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) self._check_approximate_each_value(vec, vec.get(0), vec.get(1), vec.get(2))
def test_copy_constructor(self): vec1 = Vector3R(0.3241234856402, 0.712532522433, 0.2428385977825) vec2 = Vector3R(vec1) self.assertIsInstance(vec2, Vector3R, 'Failure: Not an instance of Vector4R') self._check_approximate_each_value(vec2, vec1[0], vec1[1], vec1[2])