I am having huge set of 2D line segments. So, I know; Line number, Begin (X,Y,Z) and End (x,Y,Z) of each line segment. I want to get proximity line segments for a given line segment. Likewise for all.
To find the proximity I can apply this
If I say my data it is as;
So, at the end I want to get proximity lines as a vector for each line segment. I heard this type of vector of vector can be taken with r-tree data structures. I was searching it but still could not find the relevant one for me. Also I looked in opencv, there is a r-tree but it says something about classifier, and training phase... so, i guess it doesn't fit me.
Can anyone know how to get line no , then its neighbor lines for ex;
1 = {2,4,,7,66,32,12}
2 = {1,4,5,6}
3 = {...} .. .. this type of vector of vector using r-tree.
I know, we can get this type of vectors using kd-tree. But it is designed for the point data. So, it is hard to use kd-tree for this case i think. any help please, thank you.
Theoretically searching for the nearest Segments should be possible using any kind of spatial index or space partitioning data structure. Most often the interface of such spatial index allows to store Boxes (AABBs) or Points so in these cases you'd be forced to store bounding Boxes of Segments and then after querying for the closest Boxes check again the corresponding Segments. However it's possible to index Segments directly. E.g. in case of kd-tree it would be a version containing internal nodes defining splitting planes and leafs storing segments.
Boost.Geometry R-tree supports Segments in Boost version 1.56.0 and above. Below is the example for 2d segments using this spatial index implementation:
In case you needed ALL of the Segments that are closer than some threshold you could use iterative queries (example).
Yes, R-trees can do this. They are designed for arbitrary objects with spatial extend, not limited to point data. Actually some of the earliest examples used polygons.
Have you tried using them?
Build a segment Voronoi diagram, then take proximity candidates from neighbouring cells.