   neighbor points in Database
  I have a database table x y z colmuns have lots of points in table i want to search find neighbor point if exact point not found in table but any algorithm or way i want to search between limited reacord in table not with whole table so query with limit sample record then find neigbhour point.supose x=3 y=4 z=5so i dont query with this record where x=13 y=14 z=15x=33 y=14 z=15x=23 y=14 z=55x=33 y=14 z=35   
  Not DirectX related, moving to General Programming.What's wrong with something like "SELECT * FROM blah WHERE x>=0 AND x<=6 AND y>=1 AND y<=7 AND z>=2 AND z<=8;" or equivalent?   ;  i know this query but problem is how i find x is ? to ?y is ? to ?SELECT * FROM blah WHERE x>=? AND x<=? AND y>=? AND y<=? AND z>=? AND z<=?;" or equivalent?how i find ? values i need general formula or algo to find RANGE beause x y z depend on each other   ;  One way is to use SQL vendor-specific GIS extensions.Alternatively, select all points and calculate distance from your point into new table. Select on resulting table, using WHERE calculated_distance < desired_distance.[Edited by - Antheus on May 8, 2009 10:23:12 AM];  i want to limited search not with all the points in tables.I want to ignore only irrevlant points which are so far away from my current points.sencond problem is that current points are so many.may be 30 points per sec.i want limited search beacuse take lots of time consuming if use all points.   ;  You're basically looking for a query that selects all points within a certain area, while avoiding as much as possible points within other areas. There are techniques which rely on appropriate setup of your database indices for doing this. Beforehand, you create a binary search tree for your points (sorting by X only). This can be done implicitly by keeping your data sorted (or at least indexed) by their X values. The first step of your query is to find the smallest binary search tree node that contains the queried area. This involves, mostly, finding the points with the smallest and largest X that are contained within the area, and from there deduce the binary search node mathematically.The second step requires you to build, for every node in the first binary search tree that is large enough, a second binary search tree (sorted by Y only) containing only the points that are children of that node. You perform the second part of this query by finding again the smallest tree node that contains the queried area. The third step does the same for the Z axis. When all three query steps are done (or earlier, if nodes are too small to be worth splitting) you end up with a list of points you should work with. If your indexes are set up appropriately, you can do this in a single stored procedure, which fills a temporary table with points within the area for your actual query to work on.   ;  What is your RDBMS?You're going to need a specific index structure for neighbour search.   ;  can i use quad tree?   ;Quote:Original post by usman1266i want to limited search not with all the points in tables.I want to ignore only irrevlant points which are so far away from my current points.In order to do so, you need to check all points.Quote:sencond problem is that current points are so many.may be 30 points per sec.i want limited search beacuse take lots of time consuming if use all points.30 is not many...Either way:To select all points that are 2 units around your point (3,4,5):SELECT * FROM coordinates WHERE ((x-3)*(x-3)+(y-4)*(y-4)+(z-5)*(z-5) < 4);To avoid square root, check against 2^2.   ;Original post by AntheusTo select all points that are 2 units around your point (3,4,5):SELECT * FROM coordinates WHERE ((x-3)*(x-3)+(y-4)*(y-4)+(z-5)*(z-5) < 4);To avoid square root, check against 2^2.can you give me any referernece of this query or any formula from which this query you create?thanks