Re: How to find closest point(s) around a specific point in point cloud?




"robert" <robert.kj.karlsson@xxxxxxxxx> wrote in message news:41d03ff0-b3a2-4f54-8c80-1fc93ba227f0@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I can't find any site with information about the simplest way to
locate the n number of closest points adjacent to a point in a 3d
point cloud with scattered data.

Basically, I've got an array, call it V, with a couple of hundred
positions [x,y,z] and a value (eg [0-100).

Let's say I wanted to pick the 5 closest points around a specific
point, call it P, with a value like [x,y,z] = [10,20,30]

I'm going to have to write functions in different languages, so some
generic pseudo code would be great.


the simplest way, is likely a linear search.

one scans the cloud, calculating the distance to each point, and keeping track of the closest matches.
one can do this in multiple passes, using an array to avoid re-including previous points (this basically amounts to a special case of selection sort).


slightly more efficient, is to use a sort function (qsort, for example, with the comparrison being the distance from the point, and analogous functions in other languages, or one can roll their own). then, one then just grabs the first N points in the sorted output.

this may infact be the best approach if one is doing a "one-off" query (aka: there is little intention of repeating the query numerous times, raw performance is not all that important, or the following options are just too complicated).



potentially more efficient (especially if the cloud may be used numerous times, for example, it represents a 3D model or similar, or one is looking for the closest points from a decent number of potential locations), is to make use of a binary tree (such as a KD or BSP tree).

finding the closest point is really easy, but n-closest is a little harder (different possibilities exist with differing levels of accuracy and complexity).

simple example:
one walks the tree (top down), finding the closest points on each side of the partition;
the N closest points are within this set if (n<log2(m)) (where m is the total size of the cloud).

should be about O(log2(m)^2).

otherwise, one can mark each exhausted node (a leaf is marked exhausted and not considered on the next run, and a node is exhausted if both subnodes have been exhausted).

this process is repeated until a sufficient number of points has been located.

should be about O((n/log2(m))*log2(m)^2)


alternatively, one can do a bottom-up search, but this may not necessarily return the closest points (if near a larger dividing plane, for example, but may be very fast).

a spherical query is also possible, but is problematic (the size of the sphere is very important, but may not be known prior to the query, which would require iteration).

such sphere queries, however, are very useful in the case of physics simulation or in a particle engine, where such a sphere can represent the range of possible collisions or interferences (objects outside the sphere are assumed, simply, to not exist...).

for example, an object has exploded, do a radius query to find any other objects damaged, or to apply said explosive forces to the objects (or, in actual scenes, using linechecking or volume tracing to figure out which objects are effected and how, ...).


and so on...


Robert Karlsson

.



Relevant Pages

  • Re: How to find closest point(s) around a specific point in point cloud?
    ... point cloud with scattered data. ... Let's say I wanted to pick the 5 closest points around a specific ... The best thing I can think of is to use a voxel bounding box ... Interesting, for a random cloud of points, would this be more efficient ...
    (comp.programming)
  • Re: How to find closest point(s) around a specific point in point cloud?
    ... point cloud with scattered data. ... Let's say I wanted to pick the 5 closest points around a specific ... generic pseudo code would be great. ...
    (comp.programming)
  • Re: Query that will return date closet to another
    ... You can create a query with a calculated field like: ... The closest one can be found via the minimum value of the result. ... i do not know SQL that well so any help would be appreciated. ...
    (microsoft.public.access.queries)
  • Re: i know its a floating-point imprecision...
    ... Where Query ... Analyzer displays the closest 17-digit decimal value to the stored float, ... You might store a float like piand see what each of these shows you. ... >I understand that the value is stored in SQL Server using floating points. ...
    (microsoft.public.sqlserver.server)
  • how to get wifi transmission rate?
    ... How do you get the current transmission rate? ... The Microsoft API does ... The closest I could get was an ... OID_802_11_SUPPORTED_RATES query. ...
    (microsoft.public.windowsce.embedded)