def isTooCloseToOtherPoints(self, x, y):
     for i in range(len(self.points)):
         if NearestPoints.distance(x, y, 
             self.points[i][0], self.points[i][1]) <= RADIUS + 2:
             return True
     
     return False
 def addThisPoint(self, x, y):
     # Display this point
     self.canvas.create_oval(x - RADIUS, y - RADIUS,
         x + RADIUS, y + RADIUS)
     # Add this point to self.points list
     self.points.append([x, y]) 
     if len(self.points) > 2:
         p1, p2 = NearestPoints.nearestPoints(self.points)
         self.canvas.delete("line") 
         self.canvas.create_line(self.points[p1][0], 
             self.points[p1][1], self.points[p2][0], 
             self.points[p2][1], tags = "line")
def main():
    numberOfPoints = eval(input("Enter the number of points: "))

    # Create a list to store points
    points = []
    print("Enter", numberOfPoints, "points:", end = '')
    for i in range(numberOfPoints):
        point = 2 * [0]
        point[0], point[1] = \
            eval(input("Enter coordinates separated by a comma: "))
        points.append(point)

    # p1 and p2 are the indices in the points list
    p1, p2 = NearestPoints.nearestPoints(points)  

    # Display result
    print("The closest two points are (" +
        str(points[p1][0]) + ", " + str(points[p1][1]) + ") and (" +
        str(points[p2][0]) + ", " + str(points[p2][1]) + ")")
def mian():
    numberOfPoints = eval(input("Enter the number of points: "))

    # Create a list to store points
    points = []
    print("Enter", numberOfPoints, "points:", end = '')
    for i in range(numberOfPoints):
        point = 2 * [0]
        point[0], point[1] = \
            eval(input("Enter coordinates separated by a comma: "))

        points.append(point)

        # p1 and p2 are the indexes in the points list
        p1, p2 = NearestPoints.nearestPoints(points)

        # Display result
        print("The closest two points are("+
              str(points([p1][0]) + ", " + str(points[p1][1]) + ") and (" +
              str(points([p1][0]) + ", " + str(points[p2][1]) + ")")

mian()    # Call the main function
 def isTooCloseToOtherPoints(self, x, y):
     for i in range(len(self.points)):
         if NearestPoints.distance(x, y, self.points[i][0],
                                   self.points[i][1]) <= 2 * radius:
             return True
     return False
Esempio n. 6
0
 def isTooCloseToOtherPoints(self, x, y):
     for x in range(len(self.points)):
         if NearestPoints.distance(x, y, self.points[x][0],
                                   self.points[x][1]) <= RADIUS + 2:
             return True
     return False