def nearest(self, pt):
     d = self.data
     possibles = self.grid.nearest(pt)
     distances = [get_segment_point_dist(d[i], pt)[0] for i in possibles]
     #print "possibles",possibles
     #print "distances",distances
     #print "argmin", numpy.argmin(distances)
     return possibles[numpy.argmin(distances)]
예제 #2
0
 def nearest(self, pt):
     d = self.data
     possibles = self.grid.nearest(pt)
     distances = [get_segment_point_dist(d[i], pt)[0] for i in possibles]
     #print "possibles",possibles
     #print "distances",distances
     #print "argmin", numpy.argmin(distances)
     return possibles[numpy.argmin(distances)]
def test_combo(bins, segments, qpoints):
    G = SegmentLocator(segments, bins)
    G2 = BruteSegmentLocator(segs)
    for pt in qpoints:
        a = G.nearest(pt)
        b = G2.nearest(pt)
        if a != b:
            print a, b, a == b
            global DEBUG
            DEBUG = True
            a = G.nearest(pt)
            print a
            a = segments[a]
            b = segments[b]
            print "pt to a (grid)", get_segment_point_dist(a, pt)
            print "pt to b (brut)", get_segment_point_dist(b, pt)
            raw_input()
            pylab.clf()
            DEBUG = False
예제 #4
0
def combo_check(bins, segments, qpoints):
    G = SegmentLocator(segments, bins)
    G2 = BruteSegmentLocator(segs)
    for pt in qpoints:
        a = G.nearest(pt)
        b = G2.nearest(pt)
        if a != b:
            print(a, b, a == b)
            global DEBUG
            DEBUG = True
            a = G.nearest(pt)
            print(a)
            a = segments[a]
            b = segments[b]
            print("pt to a (grid)", get_segment_point_dist(a, pt))
            print("pt to b (brut)", get_segment_point_dist(b, pt))
            input()
            pylab.clf()
            DEBUG = False
 def nearest(self, pt):
     d = self.data
     distances = [get_segment_point_dist(
         d[i], pt)[0] for i in xrange(self.n)]
     return numpy.argmin(distances)
예제 #6
0
 def nearest(self, pt):
     d = self.data
     distances = [
         get_segment_point_dist(d[i], pt)[0] for i in range(self.n)
     ]
     return numpy.argmin(distances)