diff options
author | rcoh <rcoh@mit.edu> | 2011-01-04 13:09:41 -0500 |
---|---|---|
committer | rcoh <rcoh@mit.edu> | 2011-01-04 13:09:41 -0500 |
commit | 395e99394ead5d0d656e74fed23dc780652b6090 (patch) | |
tree | c6eff1e3bc4d7cd58b71f6435d96cea72fc9008e /pixelmappers | |
parent | 5b90941441be6ef6c945f7bdf3489db65aff90ee (diff) |
Early stages of making simplemapper use bsearch
Diffstat (limited to 'pixelmappers')
-rw-r--r-- | pixelmappers/SimpleMapper.py | 7 |
1 files changed, 5 insertions, 2 deletions
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 |