Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This works fine, the results turn out nice and they don't give me a migraine!
- def main():
- win = GraphWin('QAT',wSize,wSize)
- win.setBackground('green')
- win.setCoords(0,0,wSize,wSize)
- ptList = drawBoard(win)
- print(len(ptList), len(ptList[0]))
- print(allLocs)
- pt = win.getMouse()
- nn,d = findNN(pt,ptList)
- print(nn.getX(),nn.getY())
- def findNN(pt, ptList):
- rList = []
- d = 200
- for i in range(len(ptList)):
- for j in range(len(ptList[0])):
- x, y = pt.getX()-ptList[i][j].getX(), pt.getY()-ptList[i][j].getY()
- r = (x*x+y*y)**0.5
- if r < d:
- nn = ptList[i][j]
- d = r
- return nn,d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement