From 395e99394ead5d0d656e74fed23dc780652b6090 Mon Sep 17 00:00:00 2001 From: rcoh Date: Tue, 4 Jan 2011 13:09:41 -0500 Subject: Early stages of making simplemapper use bsearch --- pixelmappers/SimpleMapper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pixelmappers/SimpleMapper.py') diff --git a/pixelmappers/SimpleMapper.py b/pixelmappers/SimpleMapper.py index 5d4dceb..5df1032 100644 --- a/pixelmappers/SimpleMapper.py +++ b/pixelmappers/SimpleMapper.py @@ -1,11 +1,14 @@ from operationscore.PixelMapper import * import util.Geo as Geo +import sys class SimpleMapper(PixelMapper): def mappingFunction(self, eventLocation, screen): if type(eventLocation) == type(tuple()): - bestDist = 10**10 #don't kill me, I'm lazy + bestDist = sys.maxint bestPixel = None - for pixel in screen: + [x,y] = eventLocation + for (x,pixel) in screen.pixelsInRange(x-self['CutoffDist'], \ + x+self['CutoffDist']): pixelDist = Geo.dist(pixel.location, eventLocation) if pixelDist < bestDist: bestPixel = pixel -- cgit v1.2.3