What is the * fastest * intersection polyhedron detection algorithm?

Say there are n three-dimensional objects (polyhedra). The fastest way to calculate the intersection of all objects O (n ^ 2)?

I am now using a library that essentially makes T (n) equal n ^ 2:

for each object: // there are n objects
    get list of intersecting objects // this takes n steps

It literally takes n ^ 2 steps.

The only faster way I can think of is still O (n ^ 2), but T (n) = n (n + 1) / 2 or (n * n + n) / 2.

Here's the pseudo code:

for(int i = 0; i < len(objects) - 1; i++)
    for(int j = i + 1; j < len(objects); j++)
        if object at i intersects object at j:
            object at i . addToIntersectList ( object at j )
            object at j . addToIntersectList ( object at i )

Thus, we do not need to check if two objects intersect twice. I know that in the list that I iterate over there are about 3,000 objects. This algorithm takes 4,501,500 steps, while the original algorithm takes almost twice as many as 9,000,000 steps.

Am I missing something? Is this the best we can get?

+4
3

O (n²), , , , .

, , . , , , , . :

, .

+3

, StackOVerflow, : fooobar.com/questions/1499629/.... (2D), (3D).

, , , O (n Log n). , .

, , , , " " . /, . ( , , ), , , , , O (n sqrt (n)). , .

, , , , . , .

+2

. , "" .

. . neo4j- k- " ".

0

Source: https://habr.com/ru/post/1546357/


All Articles