def test_starting_out(self): translator = Translator((100, 100)) self.assertEqual(translator.global_origin_vector, Vector2D([50, 50])) translator.update(Vector2D([10, 0]), 1) self.assertEqual(translator.spacing, 10) self.assertEqual(translator.local_origin_vector, Vector2D([150, 50])) translator.update(Vector2D([5, 5]), 1) self.assertEqual(translator.spacing, 10) self.assertEqual(translator.local_origin_vector, Vector2D([100, 0]))
def test_starting_out(self): translator = Translator((100, 100)) v1 = Vector2D([1, 1]) self.assertTrue(translator.is_in_range(v1)) translator.update(Vector2D([10, 0]), 1) self.assertFalse(translator.is_in_range(v1)) translator.update(Vector2D([0, 0]), 1) v2 = Vector2D([0, 5]) self.assertTrue(translator.is_in_range(v2)) v2.y += 1 self.assertFalse(translator.is_in_range(v2))
def test_starting_out(self): translator = Translator((100, 100)) translator.update(Vector2D([0, 0]), 0.5) self.assertEqual(translator.spacing, 5) self.assertEqual(translator.local_origin_vector, translator.global_origin_vector) translator.update(Vector2D([5, 5]), 0.5) self.assertEqual(translator.spacing, 5) self.assertEqual(translator.local_origin_vector, Vector2D([75, 25])) translator.update(Vector2D([5, 5]), 2) self.assertEqual(translator.spacing, 20) self.assertEqual(translator.local_origin_vector, Vector2D([150, -50]))