# Intersection of two 3D Polyhedrons

This topic is 2435 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello to all users,
I'm making a project for my university and I need to calculate the intersection of two given 3D polyhedrons. How can I do that?
I know the x,y,z, coordinates of each vertex and also the triangles list that I use to draw each polyhedron.
Any help would be very very appreciated.
With regard,
Dimitris

##### Share on other sites
This should work:
-Create from all the edges of your polyhedron Rays (make sure that the rays are not infinite, but have the length of the tested edge),
-Intersect them with all triangles of polyhedron.

Ray to Triangle intersection: http://www.softsurfe...orithm_0105.htm

Perhaps not the best approach, but it should work.

Good luck

##### Share on other sites
Do you want the polyhedron of the intersecting volume of the two original polyhedrons, or just check if they do or do not intersect?

##### Share on other sites
I want the polyhedron, not only check

##### Share on other sites

I want the polyhedron, not only check

General polyhedron intersection is a very broad and complex problem, made even more complex when accounting for floating point inaccuracy. There's various libraries around with different characteristics. It gets even more complex if allowing degenerate and self-intersecting inputs.

Such operations are typically performed using CSG and polyhedra are only generated as final step. One disadvantage of such approach is that polyhedra aren't perfect fit, so there might be intersections left as result.

One way is to work on triangle soup. Intersect triangles, then run a post-processing pass to reconstruct final result. Quite a few simplifications can be made if limiting the solution to a well-defined problem, perhaps merely generating non-intersecting objects or similar.

##### Share on other sites
On large scale multiple intersactions, won't that make the code very slow?

##### Share on other sites

On large scale multiple intersactions, won't that make the code very slow?

Of course, but you are going for general intersection. Usually you do some filtering using convex hulls or bounding boxes/convex polyhedrons, and then you use the detailed mechanism only for the intersecting bodies

##### Share on other sites
A popular way to do this is to generate a bsp tree of of your polyhedrons and then merge the trees in the appropriate way - google for BSP and CSG together to find details on how the two are used together.

If I was going to do this in a quick and dirty way, I would simply take the triangles of one of the polyhedra (the one with the fewest triangles), extend them to planes and split (look for "polyhedral splitting" - it is a well studied problem) the other polyhedron. Then all you have to do is classify the resulting small polyhedra as in or out of the polyhedron used to generate the splitting planes. This can be done with a simple point inside mesh query. Finally you take the "inside" polyhedra and work out the union of them, which isn't to hard since they share sides and don't overlap.

##### Share on other sites
One question: any chance these are convex? That problem is much easier to solve.

1. 1
2. 2
Rutin
20
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633763
• Total Posts
3013728
×