def main(): if len(sys.argv) != 2: exit(1) numGen = int(sys.argv[1]) points = [] for i in range(numGen): randX = randint(0, 2 * numGen) randY = randint(0, 2 * numGen) temp = (randX, randY) points.append(temp) answers = computeHull(points) # for i in range(len(answers)): # print("X: ", answers[i][0], " Y: ", answers[i][1], "\n") print("Input: ", numGen, "Output: ", len(answers), "\n") # isRight = checkHull(answers, points) # if not isRight: # print("Error!") return 0
def drawHull(): hull = copy.copy(computeHull(points)) hull.append(hull[0]) for i in range(0, len(hull) - 1): x1 = hull[i][0] y1 = hull[i][1] x2 = hull[i + 1][0] y2 = hull[i + 1][1] w.create_line(x1, y1, x2, y2, width=3)
def drawHull(): points = [(191, 642), (190, 591), (181, 718), (181, 645), (166, 738), (178, 604), (161, 659), (145, 642), (118, 759), (138, 664), (107, 760), (73, 789), (85, 730), (81, 741), (37, 769), (41, 741), (172, 452), (131, 537), (131, 530), (45, 693), (84, 615), (95, 591), (52, 664), (92, 588), (21, 702), (26, 662), (135, 473), (136, 468), (43, 563), (85, 510), (22, 554), (126, 456), (51, 510), (48, 500), (97, 456), (101, 451), (166, 399), (50, 392), (52, 386), (83, 381), (70, 327), (141, 344), (106, 291), (62, 238), (126, 296), (12, 136), (53, 105), (98, 181), (79, 135), (127, 217), (60, 16), (77, 39), (83, 55), (99, 93), (120, 153), (81, 16), (165, 270), (115, 75), (160, 228), (113, 28), (122, 44), (161, 180), (136, 25), (162, 163), (180, 240)] # points = [] # for i in range(randint(3,400)): # points.append((randint(10, 800), randint(10,800))) # list(set(points)) # print(len(points)) hull = copy.copy(computeHull(points)) hull.append(hull[0]) for i in range(0,len(hull)-1): x1 = hull[i][0] y1 = hull[i][1] x2 = hull[i+1][0] y2 = hull[i+1][1] w.create_line(x1, y1, x2, y2, width=3) print(len(points))
# points = [(91, 375), (554, 55), (416, 536), (284, 169), (532, 551), (930, 308), (254, 252), (535, 665), (121, 166), (396, 416), (631, 469), (571, 343), (896, 505), (883, 244), (794, 566), (782, 754), (456, 208), (792, 705), (2, 796), (285, 437)] # scenario 4 -- x's that match up (y-aligned) FIXED # points = [(226, 243), (779, 40), (860, 790), (783, 330), (94, 650), (622, 628), (858, 36), (857, 132), (793, 585), (710, 783), (415, 456), (415, 320), (530, 240), (816, 737), (351, 532)] # scenario 5 -- x's that match up (y-aligned) FIXED # points = [(538, 380), (441, 598), (933, 215), (979, 216), (318, 623), (426, 249), (554, 442), (347, 423), (801, 653), (267, 556), (441, 404), (696, 500), (866, 332), (548, 653), (677, 440), (914, 48)] # scenario 6 -- x's that match up (y-aligned) in set A and B # points = [(201, 334), (684, 533), (388, 613), (75, 485), (406, 787), (555, 515), (631, 740), (720, 144), (573, 663), (864, 69), (135, 61), (508, 732), (543, 420), (992, 356), (791, 537), (441, 355), (747, 541), (9, 54), (157, 52), (154, 596), (737, 641), (658, 81), (370, 302), (780, 693), (573, 379), (28, 501), (435, 300), (43, 478), (510, 262), (59, 381), (468, 217), (792, 426), (629, 20), (693, 352), (257, 38), (111, 238), (459, 443), (558, 474), (138, 604), (805, 694)] # scenario 7 -- x's that match up (y-aligned) in set A and B : i can't fix this # SET C #points = [(62, 237), (24, 114), (76, 101), (89, 188), (89, 458), (250, 513), (175, 599)] # ALL POINTS #points = [(388,538),(89,188),(637,331),(190,513), (527,571),(76,101),(810,9),(550,154),(905,761), (829,422),(930,606),(89,458),(481,467),(774,233),(175,599),(861,216),(422,783),(329,337),(347,713),(987,73), (366,697),(381, 368),(379,381),(24,114),(454,513),(62, 237),(490,190),(468,663),(281,352),(250,513),(309, 558),(343,454),(480, 359),(977,721)] #print(f"==POINTS==\n{points}\n\n") hull = copy.copy(computeHull(points)) hull.append(hull[0]) for i in range(0,len(hull)-1): x1 = hull[i][0] y1 = hull[i][1] x2 = hull[i+1][0] y2 = hull[i+1][1] w.create_line(x1, y1, x2, y2, width=3) for point in points: w.create_text((point[0],point[1]),fill="darkred",font="Times 20 bold", text=f"({point[0]},{point[1]})") master = Tk() points = []