2
$\begingroup$

I am trying to NIntegrate a non-planar polygonal region defined by 4 points, something like this:

p1 = {1, 1, 1};
p2 = {-1, 1, 1};
p3 = {-1, -1, 1};
p4 = {1, -1, 4};
region = Polygon[{p1, p2, p3, p4}];
Show[Graphics3D[region]]
NIntegrate[1, {x, y, z} \[Element] region]

And this is the result I get:

enter image description here

What is the correct way of doing this? The integral works when the polygon is planar. I could separate the polygon into two triangles, but since the points vary a lot with each iteration of my script that might be an additional issue.

$\endgroup$
3
  • $\begingroup$ It says in the documentation for Polygon Degenerate polygons are not valid geometric regions: and if you evaluate RegionQ[region] it is False when region is degenerate. $\endgroup$
    – flinty
    Commented Jun 18, 2020 at 22:35
  • $\begingroup$ I see, thanks. Then what approach would you recommend? $\endgroup$
    – user97246
    Commented Jun 19, 2020 at 0:03
  • $\begingroup$ region = MeshRegion[{p1, p2, p3, p4}, {Triangle[{1, 2, 3}], Triangle[{1, 3, 4}]}]; $\endgroup$
    – flinty
    Commented Jun 19, 2020 at 0:19

1 Answer 1

2
$\begingroup$

There six interpretation of polygon for your situation, one for each edge of the tetrahedron. For each edge of the tetrahedron, the pair of faces may have a different area sum.

p1 = {1, 1, 1}; 
p2 = {-1, 1, 1}; 
p3 = {-1, -1, 1}; 
p4 = {1, -1, 4}; 
region = Tetrahedron[{p1, p2, p3, p4}]; 
Show[Graphics3D[region]]
NIntegrate[1, Element[{x, y, z}, region]]
TableForm[({#1[[1]], Area[#1[[1]]], #1[[2]], Area[#1[[2]]], Area[#1[[1]]] + Area[#1[[2]]]} & ) /@ 
   Subsets[MeshPrimitives[region, 2], {2}]]

Mathematica graphics

The table form output

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.