def test_angle_between_straights_three(self):
        point1 = np.array([0, 0])
        point2 = np.array([-1, 1])

        point3 = np.array([0, 0])
        point4 = np.array([1, 1])

        straight1 = get_straight_from_points(point1, point2)
        straight2 = get_straight_from_points(point3, point4)

        print(straight1, straight2)

        angle = angle_between_two_straight(straight1, straight2)

        self.assertAlmostEqual(angle, 90)
Beispiel #2
0
 def test_calculate_straight_from_points_one(self):
     point_1 = (0, 0)  # x, y
     point_2 = (1, 1)
     a, b, c = get_straight_from_points(point_1, point_2)
     self.assertEqual(a, 1)
     self.assertEqual(b, -1)
     self.assertEqual(c, 0)
Beispiel #3
0
 def __init__(self):
     checkpoints = self._load_board()
     checkpoints = self._order_checkpoints(checkpoints)
     self.dots = checkpoints
     self.current_checkpoint_index = 0
     self._last_car_position = np.zeros((2, ))
     self.car_position = self._last_car_position
     self.car_direction = np.zeros((2, ))
     self.current_road_straight_line = get_straight_from_points(
         self.current_checkpoint, self.next_checkpoint)
     self.car_size = 100  # hardcoded for debugging
Beispiel #4
0
    def distance_to_road(self):
        a, b, c = get_straight_from_points(self.current_checkpoint,
                                           self.last_checkpoint)

        if a == 0:  # parallel to OY
            return abs(self.current_checkpoint[0] - self.car_position[0])
        if b == 0:  # parallel to OX
            return abs(self.current_checkpoint[1] - self.car_position[1])

        tmp = point_to_straight_distance((a, b, c), self.car_position)
        return tmp
Beispiel #5
0
 def car_direction_straight(self):
     return get_straight_from_points(self.car_position,
                                     self.car_front_point)
Beispiel #6
0
 def _forward_checkpoint(self):
     self.current_checkpoint_index = (self.current_checkpoint_index +
                                      1) % len(self.dots)
     self.current_road_straight_line = get_straight_from_points(
         self.current_checkpoint, self.next_checkpoint)