1

I have an array of pointclouds (a cluster of points that have been determined to be in their own region).

The goal is to combine these individual clusters that are either

i. Intersecting

ii. Within some minimum distance from eachother

Check ii makes this more difficult. In order to deal with these pointcloud's quickly, I am creating AABB (axis aligned bounding boxes which are aligned along the X axis).

My current method is to use some properties of the Separating Axis Theorem:

  1. Create AABB for each pointcloud
  2. For each AABB, check if they are overlapping by projecting these onto a random axis and then sorting these linear projections by where they fall on this line o(nlog(n)). I then walk through this list to check for intersections O(N) using the SAT. Most AABB's linear projections will not overlap and are therefore not intersecting, and the ones that do I can check manually (because no overlap in 1D guarantees no intersection, but the converse is not true).

The last part is where I am stuck. The above 1D projection was done to avoid O(n^2) pairwise checks for intersections. But in order to combine the convex polygons that are within a certain threshold but NOT intersecting, I can't see a way around an O(N^2) pairwise check.

Is there a way to construct some tree or graph to combine all convex polygons that are within a certain distance to eachother without checking each pairwise combination?

If use you use my steps from 1 & 2, you can assume the remaining pointclouds/AABB are NOT intersecting.

EDIT

A potential solution would be to add the threshold/2 to the AABB width and height, and check for intersections. If they intersect, then I can check for both actual intersections (which is fast for AABB), and the minimum distance between the two.

DaynaJuliana
  • 1,144
  • 1
  • 14
  • 33
  • 1
    Can you enlighten me about the definition of AABB? – Patrick the Cat Mar 27 '16 at 02:41
  • An axis aligned bounding box (alligned along the X axis). https://studiofreya.com/3d-math-and-physics/simple-aabb-vs-aabb-collision-detection/ – DaynaJuliana Mar 27 '16 at 03:02
  • 1
    I think your question sounds too fancy, which also implies confusing. Basically you are checking if regular boxes are too close to each others, but you have not defined boxes as individual points in cluster (pointcloud you said) or center of the cluster with its radius being the threshold in your question. Can you clarify the description of your problem? Nice job AABB:D – Patrick the Cat Mar 27 '16 at 03:31
  • Yes. I am adding AABB (axis alligned bounding boxes) to these point clouds. I want to check for intersections, or if any box is within a minimum distance from another box. I can do the first part of this in nlogn. The 2nd part I cannot do without N^2 solution. I tried to make this more clear though ! – DaynaJuliana Mar 27 '16 at 04:13
  • If two shapes intersect, their orthogonal prohections interaect. If two shapes are closer than X to each other, their orthogonal projections are closer than X to each other. You are using the first fact to weed out non-intersecting pairs, why not use the second? – n. m. could be an AI Mar 27 '16 at 05:49
  • 1
    Have a look at [this](https://www.cs.umd.edu/~mount/Papers/crc04-intersect.pdf). And if you are lazy like me you can use [this](http://doc.cgal.org/latest/AABB_tree/). Also for a giggle you can look at [this](https://www.google.com/search?espv=2&biw=1216&bih=611&q=All+About+the+Backstreet+Boys&oq=All+About+the+Backstreet+Boys&gs_l=serp.12...10745.10745.0.11631.1.1.0.0.0.0.141.141.0j1.1.0....0...1c.1.64.serp..0.0.0.bNxUNLyYp8U) Thank you for the question I learnt a lot. GJ AABB. – Patrick the Cat Mar 27 '16 at 06:17
  • I don't think that works, as it only takes a point prmitive for distance queries. And yes, while the orthogonal projections will be a certain distance from each other, I can't walk through my sorted list in O(n) because they may not be next to eachother in this list – DaynaJuliana Mar 27 '16 at 06:19
  • If you are answering to a specific user's comment please tag with the username like this: @DaynaJuliana. "it only takes a point prmitive for distance queries" --- you need to be able to calculate the distance between the boxes yourself. "I can't walk through my sorted list in O(n)" --- if you can do it for intersections, you can do the same in exactly the same way for distances; extend each projection by X/2 to either side and re-sort. – n. m. could be an AI Mar 27 '16 at 08:20
  • @n.m. that was what I referenced in my edit section as an idea – DaynaJuliana Mar 27 '16 at 17:38
  • That's a good idea, why not use it? – n. m. could be an AI Mar 27 '16 at 18:24
  • Have you thought about also projecting the clusters that are too close together on the X-axis onto the Y-axis? They may only look close together in one dimension but not the other. – m69's been on strike for years Mar 27 '16 at 20:58
  • @m69 yes I'm doing that, sorting in both the X and y direciton – DaynaJuliana Mar 28 '16 at 03:00

2 Answers2

0

I ended up using the normal of my random axis, and checked for both overlaps in 1D in both directions which speed up my algorithm considerably (removed slowdown if there was clustering along one axis).

For the distance threshold, the minimum the AABB distance padding on all sides needed to guarantee an intersection was A/2. This captures all cases where the AABB are seperated only in the x or y direction ( the diagonal case requires A*sqrt(2)/4)

DaynaJuliana
  • 1,144
  • 1
  • 14
  • 33
0

I think the problem of finding intersecting boxes for a given set of intersecting boxes is called 'spatial join'. There are dedicated algorithms such as TOUCH. However, I found that simply iterating through the boxes and checking for overlap is quite efficient if you use a spatial index. That means for each for box you query the spatial index for intersecting boxes. Classically you could use an R-Tree or X-Tree for that.

Personally I got very good results with the PH-Tree (my own Java implementation), for example with datasets of about 1,200,000 3D boxes (6000 intersecting boxes), loading the index and performing the queries takes in total about 6 seconds on a desktop machine.

EDIT

I'm not sure about the complexity, but it seems to be below O(n * log n).

TilmannZ
  • 1,784
  • 11
  • 18