Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to best store lines in a kd-tree

I know kd-trees are traditionally used to store points, but I want to store lines instead. Would it be best to split the line at every intersection with the splitting of the kd-tree? or would storing just the end-points into kd-suffice for nearest neighbor finding?

like image 813
newDelete Avatar asked Oct 28 '10 23:10

newDelete


1 Answers

The kd-tree itself is designed for point objects. Not even for boxes, spheres or something like this. I believe you can somehow use a 6d tree that stores minx, maxx, miny, maxy, minz, maxz; but I'm not entirely sure on how to query it correctly.

The R*-tree (Wikipedia) might be a better choice here. It is really designed for objects with a spatial extend. If you look up the related publications, they even experimented with different approximations of complex objects; for example whether it pay off to triangularize them, use a circumsphere, bounding box, and interestingly enough IIRC the 5-corner-polygon provided the best performance in some cases.

Anyway, the R*-tree family might be an interesting choice.

like image 57
Has QUIT--Anony-Mousse Avatar answered Oct 12 '22 10:10

Has QUIT--Anony-Mousse