Intersection of two 3D Polyhedrons

Started by
15 comments, last by the_edd 11 years, 12 months ago
Sorry for the late answer, yes the polyhedra are convex
Advertisement

Sorry for the late answer, yes the polyhedra are convex


Then it's much easier: there are libraries that convert between vertex representations and hyperplane representations (and back), you just need to convert both polyhedra to hyperplane (just planes actually in 3d), take the union of these sets planes and convert it to vertex representation.

If you want a more direct approach, in 3d, you can take one polyhedron, and for each triangle, generate a plane using the triangle normal and one of it's vertices. Take these planes, and intersect it with the other polyhedron, keeping only the inside half space. Specifically, throw away all triangles whose vertices are all in the outside half space, and keep all the triangles, whose vertices are in the inside half space. Then for all the triangles that cross the plane, clip them to the inside half space. The new vertices that result from the clipped edges will now form a convex polygon embedded within the the intersection plane. Triangulate this. Repeat this for each triangle/plane of the first polyhedron, and you're done!

I'm interested. Please share links.

Previously "Krohm"

Thanks for the reply - I will try to implement your algorithm
Hello Crowley99,
do you have some links that can help us implement one of the two given algorithms?
Regards,
Dimitris
Hello Dimitris

If the volumes are convex, it's possible to use the Séparating Axis Theorem (SAT) method. (http://en.wikipedia.org/wiki/Hyperplane_separation_theorem)
This method is well documented. I can give you my implementation "as an example" if you wish (for what it's worth of course smile.png )

What's more with this method you can get the penetration depth if you need it.

Nico rolleyes.gif
If it was calculating the intersection volume you meant (I'm not clear whether you meant this or just how far they 'poke' each other) it is probably best to google for CSG of convex hulls.

http://en.wikipedia.org/wiki/Constructive_solid_geometry

'QHull' is a library that may have an implementation to look at I believe, and also probably there is one in Dave Eberly's Geometric Tools http://www.geometrictools.com/ (he's a great egghead and has got libraries for everything lol, he wrote the NDL / gamebryo stuff).

In games the convex hulls are often known as 'brushes' and are widely used in quake derived stuff and unreal, if you have a look at dealing with their maps, or gtkradiant source you might get some ideas.

If you can valmorphanize your polygon representation into a set of planes defining the sides of a brush, you can then add planes (or their opposites) from one brush to another to split it up and do CSG jiggery pokery. Then you can use a routine to rebuild the brush from a set of planes back into a set of polygons (using e.g. the intersection of 3 planes to form a vertex) and chuck out any irrelevant planes / polys that have been clipped out by inserted planes. That's how I did it anyway.
GJK (Gilbert Johnson Keerthi) is another well-known algorithm for finding the intersection or closest features of polyhedra.

EDIT: this video has a really good explanation of how it works. The forums on that site are also worth visiting to find enhancements etc.

This topic is closed to new replies.

Advertisement