Archived

This topic is now archived and is closed to further replies.

chrisbk

box / plane intersection => volume

Recommended Posts

chrisbk    122
Hi all I have a box centered around the origin (lenght of a side = 1), and I have a plane ( i know the equation of this plane) This plane cut box on two parts . And what I would like to compute is the volume of one of these parts... and I don''t know how to Is there a nice maths formula for this or something else ? Thks for answering chris

Share this post


Link to post
Share on other sites
wolverine    358
I''m not an expert on this, but here''s my try.
You can have some special cases.

The first, and more basic case, is if the plane cuts the box in two smaller (rectangular) boxes. This is easy to check because you can determine if the vector of the plane makes a 90 degree angle with any of the of the box''s vectors. if it does, it means that the plane cuts the box in two different rectangular boxes. Since it is a rectangular box, you can easily calculate the volume of one of them by finding the intersectation points of the plane and the box.

Another case is if the plane cuts the box by its diagonals, dividing the box in two equal 3D triangles (i dont know the name for this in english ?prisma?). You can easily see that the volume of each of these triangles is exactly half of the volume of the original box.

The most general case is if the plane cuts the box in any manner. Im not sure of this, but i think that any resulting object of the cut can be sub-divided in one rectangular box and one 3D triangle. You can find the box and the triangle with the help of the intersectation points resulting from the cut. The biggest problem is finding the volume of the 3D trieangle since it can have some nasty position and you''ll have to find out it''s height in order to calcultate it''s volume.

Like i said, i''m not an expert on this matter. This is just my humble opinion. My analysis may be wrong...

Share this post


Link to post
Share on other sites
chrisbk    122
Hi !

I thank you for answering . The pb is that there is 0.001% (approximetly) chance that I get a special case...

Howewer, in the meantime I found on the web a general formula which -suprisely- seems to work ... (if you re intersted in, i can post it here), and so I am using it

bye !


Chris

Share this post


Link to post
Share on other sites
chrisbk    122
OK, here is the things .

It assumes that you know the hull of your volume :
(i ll post it as source code, it''s hard to write mathematical formula in plain text


for (int i =0;i{
float a,b,c;

a = (tab[0].y+tab[1].y) * (tab[0].z-tab[1].z) +
(tab[1].y+tab[2].y) * (tab[1].z-tab[2].z) +
(tab[2].y+tab[0].y) * (tab[2].z-tab[0].z) ;

b = (tab[0].z+tab[1].z) * (tab[0].x-tab[1].x) +
(tab[1].z+tab[2].z) * (tab[1].x-tab[2].x) +
(tab[2].z+tab[0].z) * (tab[2].x-tab[0].x) ;

c = (tab[0].x+tab[1].x) * (tab[0].y-tab[1].y) +
(tab[1].x+tab[2].x) * (tab[1].y-tab[2].y) +
(tab[2].x+tab[0].x) * (tab[2].y-tab[0].y) ;

float td = - 1/3 * (a * (tab[0].x + tab[1].x +tab[2].x)
+b * (tab[0].y + tab[1].y +tab[2].y )
+c * (tab[0].z + tab[1].z +tab[2].z ) );

d+= (td);

tab+=3;
}

volume = 1/6 * fabs(d);




et voila

Share this post


Link to post
Share on other sites