def test_givenRadianValueOfPi_whenCreateOrientationFromRadian_thenReturnOrientationWith180Degrees( self, ): expected_orientation = Orientation(180) actual_orientation = Orientation.from_radian(math.pi) self.assertEqual(actual_orientation, expected_orientation)
def calculate_angle_between_positions( first_position: Position, second_position: Position) -> Orientation: first_x, first_y = first_position.to_tuple() second_x, second_y = second_position.to_tuple() angle = -math.atan2(second_y - first_y, second_x - first_x) if angle < 0: angle += 2 * math.pi return Orientation.from_radian(angle)