def test_non_moving_A_negative_x_y_z_quadrant(self): # 13 plane_a_location, plane_a_velocity = [0, 0, 0], [0, 0, 0] plane_b_location, plane_b_velocity = [-500, -500, -500], [10, 10, 10] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_moving_2_planes_neg_x_y_pos_z_quadrant_collision(self): # 31 plane_a_location, plane_a_velocity = [-50, -50, 10], [-20, -20, 20] plane_b_location, plane_b_velocity = [-500, -500, 500], [10, 10, -10] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_moving_2_planes_toward_on_neg_x_axis(self): # 25 plane_a_location, plane_a_velocity = [0, 0, 0], [-10, 0, 0] plane_b_location, plane_b_velocity = [-500, 0, 0], [10, 0, 0] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_same_direction_same_speed_boundry_touching(self): # 2 plane_a_location, plane_a_velocity = [0, 0, 0], [100, 100, 100] plane_b_location, plane_b_velocity = [400, 0, 0], [100, 100, 100] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_non_moving_A_with_B_moving_neg_Z(self): # 11 plane_a_location, plane_a_velocity = [0, 0, 0], [0, 0, 0] plane_b_location, plane_b_velocity = [0, 0, 500], [0, 0, -30] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_7_hit_past_4(self): # 62 plane_a_location, plane_a_velocity = [-528, 828, -218], [305, 869, 943] plane_b_location, plane_b_velocity = [-354, 719, -95], [ 212.42247572305172, 979.6673853425588, 861.772976783827 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_6_hit_past_3(self): # 61 plane_a_location, plane_a_velocity = [-79, 645, -409], [221, 550, 302] plane_b_location, plane_b_velocity = [-279, 746, -298], [ 286.1493300824687, 578.0142119354615, 309.38359074267976 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_5_hit_past_2(self): # 60 plane_a_location, plane_a_velocity = [138, 721, 881], [428, 967, 977] plane_b_location, plane_b_velocity = [242, 667, 645], [ 415.0613107671489, 1008.3443173187657, 1007.1902748766527 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_4_hit_past_1(self): # 59 plane_a_location, plane_a_velocity = [97, -666, -541], [647, 17, 380] plane_b_location, plane_b_velocity = [-3, -517, -804], [ 683.1518470283609, 10.013600114151117, 388.3171427212487 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_3(self): # 58 plane_a_location, plane_a_velocity = [-577, 331, 814], [256, 443, 940] plane_b_location, plane_b_velocity = [191, 451, 511], [ -596.5978391630134, 229.3418302813451, 1144.5013910164269 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_2(self): # 57 plane_a_location, plane_a_velocity = [892, 473, 19], [-247, -155, -645] plane_b_location, plane_b_velocity = [-234, -875, -135], [ -116.51520559668512, -22.561532552033437, -626.3886936272655 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_1(self): # 56 plane_a_location, plane_a_velocity = [922, -973, -729], [7, 30, 375] plane_b_location, plane_b_velocity = [721, -470, -50], [ 66.6938748861153, -152.15410351277828, 162.9989590441641 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_cross_paths_in_past3(self): # 47 plane_a_location, plane_a_velocity = [-200, -100, -100], [-9999, -9999, -9999] plane_b_location, plane_b_velocity = [100, 100, 100], [9999, 9999, 9999] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_8_hit_past_5(self): # 63 plane_a_location, plane_a_velocity = [392, 961, -105], [536, 980, 377] plane_b_location, plane_b_velocity = [344, 825, -96], [ 533.670023347531, 1127.3710232686612, 336.2254085817933 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_9(self): # 64 plane_a_location, plane_a_velocity = [526, 300, 937], [249, 894, 197] plane_b_location, plane_b_velocity = [331, -224, -853], [ 355.7580592596675, 1168.8298687698198, 1343.2064605649434 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_14(self): # 69 plane_a_location, plane_a_velocity = [293, -870, 81], [999, 263, 48] plane_b_location, plane_b_velocity = [-277, -15, -990], [ 1090.0561667337115, 36.170515948336984, 282.24372663557847 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_13(self): # 68 plane_a_location, plane_a_velocity = [380, 334, -829], [521, 684, 142] plane_b_location, plane_b_velocity = [387, 615, -477], [ 523.0612614187343, 608.8432375015374, 50.67026329300751 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_11(self): # 66 plane_a_location, plane_a_velocity = [-423, -393, 129], [867, 507, 707] plane_b_location, plane_b_velocity = [479, 997, -616], [ 761.3139710461941, 333.9994256337078, 801.17458389141 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_10(self): # 65 plane_a_location, plane_a_velocity = [-115, 638, -649], [594, 626, 404] plane_b_location, plane_b_velocity = [-531, 945, 744], [ 630.2134364559457, 606.4731470090487, 120.32808109509146 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_random_points_12(self): # 67 plane_a_location, plane_a_velocity = [-331, -627, -708], [514, 637, 783] plane_b_location, plane_b_velocity = [-764, 994, -810], [ 551.157171920058, 395.47838251962366, 783.6518802091239 ] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def test_plane_A_neg_x_y_pos_z_quadrant_towards_plane_B_neg_x_y_pos_z_quadrant( self): # 41 plane_a_location, plane_a_velocity = [-400, -700, 300], [100, 100, -100] plane_b_location, plane_b_velocity = [700, 400, -800], [-100, -100, 100] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue( CollisionDetection().determine_collision(plane_a, plane_b), "Not implemented yet")
def collision_detection_generator(): """ This will create threads for each plane and call the collision detection. The collision detection will return true or false. If true, the object will be placed into a list. Once all the threads have completed their calculations and returned the booleans, the list will contain all of the closest 10 planes that are on a collision course with the PA :return: list_closest: returns a list with the closest airplanes on a collision course with the PA """ queue = Queue() thread_list = [] # print "Begin Set","-"*100 # for i in nearby_planes_list: # print "*"*20 # print i.to_string() # print "End Set","-"*100 #print nearby_planes_list # for i in nearby_planes_list: # print i.id_code for i in nearby_planes_list: t = Thread(target=CollisionDetection().build_collision_list, args=(primary_aircraft, i, queue)) thread_list.append(t) t.start() for i in thread_list: i.join() collision_course_planes = [] if queue.qsize() > 0: for i in iter(queue.get, None): collision_course_planes.append(i) if queue._qsize() == 0: break # for i in collision_course_planes: # print i.id_code return collision_course_planes
def collision_detection_generator(): """ This will create threads for each plane and call the collision detection. The collision detection will return true or false. If true, the object will be placed into a list. Once all the threads have completed their calculations and returned the booleans, the list will contain all of the closest 10 planes that are on a collision course with the PA :return: list_closest: returns a list with the closest airplanes on a collision course with the PA """ dummy_pa = PlaneObject("PA", 1 ,1 ,1 ,2, 2, 2) dummy_plane1 = PlaneObject("1", 1, 1, 1, 2, 2, 2) dummy_plane2 = PlaneObject("2", 1, 1, 1, 2, 2, 2) dummy_plane3 = PlaneObject("3", 1, 1, 1, 2, 2, 2) dummy_plane4 = PlaneObject("4", 1, 1, 1, 2, 2, 2) dummy_plane5 = PlaneObject("5", 1, 1, 1, 2, 2, 2) dummy_plane6 = PlaneObject("6", 1, 1, 1, 2, 2, 2) dummy_plane7 = PlaneObject("7", 1, 1, 1, 2, 2, 2) dummy_plane8 = PlaneObject("8", 1, 1, 1, 2, 2, 2) dummy_plane9 = PlaneObject("9", 1, 1, 1, 2, 2, 2) dummy_plane10 = PlaneObject("10", 1, 1, 1, 2, 2, 2) nearby_planes_list.append(dummy_plane1) nearby_planes_list.append(dummy_plane2) nearby_planes_list.append(dummy_plane3) nearby_planes_list.append(dummy_plane4) nearby_planes_list.append(dummy_plane5) nearby_planes_list.append(dummy_plane6) nearby_planes_list.append(dummy_plane7) nearby_planes_list.append(dummy_plane8) nearby_planes_list.append(dummy_plane9) nearby_planes_list.append(dummy_plane10) # pool = ThreadPool(processes=10) # c_d = CollisionDetection() # queue = Queue() # for i in nearby_planes_list: # pool.apply_async(c_d.determine_collision(dummy_pa, i, queue)) #A variant of the apply() method which returns a result object. # queue.join() # collision_course_planes = [] # for i in iter(queue.get, None): # collision_course_planes.append(i) # if queue._qsize() == 0: # break # # print(collision_course_planes) # for i in collision_course_planes: # print i.id_code # pool = ThreadPool(processes=10) # c_d = CollisionDetection() # queue = Queue() # for i in nearby_planes_list: # pool.apply(c_d.determine_collision, (dummy_pa, i, queue)) # queue.join() # collision_course_planes = [] # for i in iter(queue.get, None): # collision_course_planes.append(i) # if queue._qsize() == 0: # break # # print(collision_course_planes) # for i in collision_course_planes: # print i.id_code c_d = CollisionDetection() queue = Queue() for i in nearby_planes_list: Thread(target=c_d.determine_collision(dummy_pa, i ,queue)).start() queue.join() ## block until all tasks are done collision_course_planes = [] for i in iter(queue.get, None): collision_course_planes.append(i) if queue._qsize() == 0: break print collision_course_planes for i in collision_course_planes: print i.id_code return collision_course_planes
def test_non_moving_A_positive_x_y_z_quadrant(self): # 12 plane_a_location, plane_a_velocity = [0, 0, 0], [0, 0, 0] plane_b_location, plane_b_velocity = [500, 500, 500], [-10, -10, -10] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue(CollisionDetection().determine_collision(plane_a, plane_b))
def test_non_moving_A_with_B_moving_pos_Z(self): # 10 plane_a_location, plane_a_velocity = [0, 0, 0], [0, 0, 0] plane_b_location, plane_b_velocity = [0, 0, -500], [0, 0, 30] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue(CollisionDetection().determine_collision(plane_a, plane_b))
def test_plane_A_not_catching_up_to_B(self): # 5 plane_a_location, plane_a_velocity = [0, 0, 0], [100, 100, 0] plane_b_location, plane_b_velocity = [400, 400, 0], [200, 200, 0] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse(CollisionDetection().determine_collision(plane_a, plane_b))
def test_edge4(self): # 55 plane_a_location, plane_a_velocity = [0, 0, 0], [0, 0, 0] plane_b_location, plane_b_velocity = [-401, 0, 0], [100, 0, 0] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue(CollisionDetection().determine_collision(plane_a, plane_b))
def test_collision_beginning(self): # 51 plane_a_location, plane_a_velocity = [0, 0, 0], [0, 0, 0] plane_b_location, plane_b_velocity = [400, 0, 0], [100, 0, 0] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse(CollisionDetection().determine_collision(plane_a, plane_b))
def test_random_cross_in_past6(self): # 50 plane_a_location, plane_a_velocity = [50, 150, 40], [-70, -420, -90] plane_b_location, plane_b_velocity = [350, 20, 840], [110, -440, 370] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse(CollisionDetection().determine_collision(plane_a, plane_b))
def test_cross_paths_in_past5(self): # 49 plane_a_location, plane_a_velocity = [-400, -400, -400], [-400, 0, 0] plane_b_location, plane_b_velocity = [400, -1200, -400], [0, -400, 0] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertFalse(CollisionDetection().determine_collision(plane_a, plane_b))
def test_non_moving_A_plane_B_entering_plane_A_edge(self): # 44 plane_a_location, plane_a_velocity = [-400, 399, 0], [100, 0, 0] plane_b_location, plane_b_velocity = [0, 0, 0], [0, 0, 0] plane_a = self.plane_helper(self.a_id_code, plane_a_location, plane_a_velocity) plane_b = self.plane_helper(self.b_id_code, plane_b_location, plane_b_velocity) self.assertTrue(CollisionDetection().determine_collision(plane_a, plane_b))