Volume of two intersected boxes.

Started by
5 comments, last by eq 16 years, 4 months ago
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.
Advertisement
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 :)
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...
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 = OBBFor 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 edgesEnd       

Does the above work?
If so how does one find the volume of a convex mesh as produced above?
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?
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.
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.

This topic is closed to new replies.

Advertisement