예제 #1
0
 def test_get_direction_to_combination(self):
     start = Point(1, 2)
     end = Point(5, 0)
     answer = start.get_direction_to(end)
     self.assertEqual(answer, CompositeDirection(E, E, E, E, S, S))
     magnitude = sqrt(20)
     self.assertAlmostEqual(answer.value[0], 4/magnitude, places=7)
     self.assertAlmostEqual(answer.value[1], -2/magnitude, places=7)
예제 #2
0
 def test_get_direction_to_west(self):
     start = Point(1, 2)
     end = Point(-1, 2)
     answer = start.get_direction_to(end)
     self.assertEqual(answer, CompositeDirection(W))
     self.assertEqual(answer.value, (-1.0, 0))
예제 #3
0
 def test_get_direction_to_south(self):
     start = Point(1, 2)
     end = Point(1, 0)
     answer = start.get_direction_to(end)
     self.assertEqual(answer, CompositeDirection(S))
     self.assertEqual(answer.value, (0, -1.0))