Sign in to follow this  

Volume of two intersected boxes.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all! I need to calculate the volume of two intersection OBB's (wich is the same as the intersection of one AABB and one OBB). Is there a simpler method than intersecting them using CSG at polygon level and then calculate the remaining volume? I could live with an approximation of some sort, I'd just like to get an ratio of how much of box A is inside box B. Maybe I could distribute points on a grid inside A and then calculate the number of points inside B. I.e: insideRatio = pointsInsideB / totalPoints; Any hints suggestions are welcome.

Share this post


Link to post
Share on other sites
A very crude approximation could be to use the separating axis theorem to compute an approximate penetration depth, and use the ratio of this to the extents of the box. If you test all potential separating axes and the objects are intersecting, the axis with the smallest overlap gives an approximate collision normal and the overlap is an approximation of the penetration depth. This would probably be quite fast to compute but would be quite inaccurate in some cases :)

Share this post


Link to post
Share on other sites
Yeah, I was thinking about using the penetration depth as an approximation.
Haven't gotten around to try it out yet though.
The approximation using sample points works but is very slow since I need around 200-300 points for each test to get a good approximation (and there's quite a few tests in my application).

I still think that a full blown CSG version would be faster but there's to much code in there...

Share this post


Link to post
Share on other sites
On a second thought there isn't to much code involved to create the intersected volume since both the AABB, OBB and intersection is convex:


Intersection = OBB
For each plane in AABB
For each polygon in Intersection
Clip polygon agains plane and add each new edge to list of open edges
End
If list of open edges is empty continue with next plane (i.e no clipping against plane was done)
Add a new polygon to Intersection from the list of open edges
End


Does the above work?
If so how does one find the volume of a convex mesh as produced above?

Share this post


Link to post
Share on other sites
I keep on answering my self :)
The volume of a convex mesh should be the sum of the volume of all terahedrons formed by the center vertex and all triangles on the mesh surface, right?

Share this post


Link to post
Share on other sites
Yep you've answered yourself pretty well :) Clipping one convex polyhedron by the planes of the faces of the other will generate a convex polyhedron as you've said, and yes the volume is given by the sum of the volumes of the tetrahedra formed by the centroid and each triangle in the mesh.

Share this post


Link to post
Share on other sites
Implemented the clipping method and it seems to work ok.
I've only tested it by rotating the boxes around one axis and project them in 2d so far but all calculations is done fully in 3d.

Prints percentage of smaller box's volume that intersects the larger box

Edit: The bounding values of the projection axis are -1 and 1 for both boxes, so they are fully overlapping there.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this