Jump to content

  • Log In with Google      Sign In   
  • Create Account

Intersection of two 3D Polyhedrons


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 sgdimitris   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 March 2012 - 05:56 AM

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

Sponsor:

#2 Vlad86   Members   -  Reputation: 130

Like
1Likes
Like

Posted 12 March 2012 - 07:00 AM

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

#3 Erik Rufelt   Crossbones+   -  Reputation: 3639

Like
0Likes
Like

Posted 12 March 2012 - 07:20 AM

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

#4 sgdimitris   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 March 2012 - 07:49 AM

I want the polyhedron, not only check

#5 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

Posted 12 March 2012 - 09:07 AM

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.

#6 darksheikh   Members   -  Reputation: 102

Like
0Likes
Like

Posted 14 March 2012 - 09:21 AM

On large scale multiple intersactions, won't that make the code very slow?
Live Television: http://www.hdlivestreams.com
Online Shopping: http://www.shoppynow.com

#7 Rekai   Members   -  Reputation: 102

Like
0Likes
Like

Posted 14 March 2012 - 10:41 AM

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

#8 Crowley99   Members   -  Reputation: 178

Like
0Likes
Like

Posted 14 March 2012 - 11:27 PM

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.

#9 Crowley99   Members   -  Reputation: 178

Like
0Likes
Like

Posted 14 March 2012 - 11:28 PM

One question: any chance these are convex? That problem is much easier to solve.

#10 sgdimitris   Members   -  Reputation: 100

Like
0Likes
Like

Posted 08 April 2012 - 04:15 AM

Sorry for the late answer, yes the polyhedra are convex

#11 Crowley99   Members   -  Reputation: 178

Like
1Likes
Like

Posted 10 April 2012 - 12:48 AM

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!



#12 Krohm   Crossbones+   -  Reputation: 3253

Like
0Likes
Like

Posted 10 April 2012 - 01:14 AM

I'm interested. Please share links.

#13 sgdimitris   Members   -  Reputation: 100

Like
0Likes
Like

Posted 11 April 2012 - 11:10 AM

Thanks for the reply - I will try to implement your algorithm

#14 sgdimitris   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 April 2012 - 04:10 AM

Hello Crowley99,
do you have some links that can help us implement one of the two given algorithms?
Regards,
Dimitris

#15 Tournicoti   Prime Members   -  Reputation: 684

Like
0Likes
Like

Posted 18 April 2012 - 11:54 AM

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 Posted Image )

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

Nico Posted Image

#16 lawnjelly   Members   -  Reputation: 429

Like
0Likes
Like

Posted 18 April 2012 - 01:43 PM

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.

#17 e‍dd   Members   -  Reputation: 2105

Like
0Likes
Like

Posted 19 April 2012 - 03:30 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS