Go to the documentation of this file.00001
00002
00003
00004
00005 from scipy.spatial import KDTree
00006 import numpy as np, math
00007
00008 x, y = np.mgrid[0:5, 2:8]
00009 tree = KDTree(zip(x.ravel(), y.ravel()))
00010
00011 tree.data
00012
00013 pt = np.array([0,0])
00014
00015 print 'Querying neibors for ', pt
00016
00017 print 'k=1'
00018 print 'Output of query:', tree.query(pt)
00019 print 'Neighbors:', tree.data[tree.query(pt)[1]]
00020
00021 print 'k=2'
00022 print 'Output of query:', tree.query(pt, 2)
00023 print 'Neighbors:', tree.data[tree.query(pt, 2)[1]]
00024
00025 print ''
00026 print 'Simple query returns (array of distances, array of indices)'
00027 print ''
00028
00029
00030
00031
hrl_lib
Author(s): Cressel Anderson, Travis Deyle, Advait Jain, Hai Nguyen, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:34:06