I'm trying to find the volume an ellipsoid and a prism share. I tried using RegionIntersection
, but it returns unevaluated.
Input:
sample3D=Ellipsoid[{0, 0, 0}, {572, 96, 572}];
beam3D=Prism[{{2864.79, 0, -2810}, {0, 10.0001, -2810}, {-2864.79,
0, -2810}, {2864.79, 0, 2810}, {0, 10.0001, 2810}, {-2864.79, 0,
2810}}];
Volume@RegionIntersection[beam3D, sample3D]
Returns:
Volume[BooleanRegion[#1 && #2 &, {Prism[{{1145.93, 0, -2810}, {0,
10.0004, -2810}, {-1145.93, 0, -2810}, {1145.93, 0, 2810}, {0,
10.0004, 2810}, {-1145.93, 0, 2810}}],
Ellipsoid[{0, 0, 0}, {572, 96, 572}]}]]
Both the ellipsoid and prism are of the same dimension and are recognized by RegionQ
as regions.
A two-dimensional example of a triangle and an ellipse works fine. Input:
sample2D=Disk[{0, 0}, {572, 10}];
beam2D=Triangle[{{2864.79, 0}, {0, 10.0001}, {-2864.79, 0}}];
Area@RegionIntersection[sample2D, beam2D]
Returns:
8927.06
I already read somewhere, that Mathematica versions below 11.3 had problems with Region
functions, but I'm using version 12.0.
Thanks a bunch in advance!
Edit:
The original problem can be worked around by applying BoundaryDiscretizeRegion
to both regions. Input:
sample3D$edit1 =
BoundaryDiscretizeRegion@Ellipsoid[{0, 0, 0}, {572, 96, 572}];
beam3D$edit1 = BoundaryDiscretizeRegion@
Prism[{{2864.79, 0, -2810}, {0, 10.0001, -2810}, {-2864.79,
0, -2810}, {2864.79, 0, 2810}, {0, 10.0001, 2810}, {-2864.79, 0,
2810}}];
Volume@RegionIntersection[beam3D$edit1, sample3D$edit1]
Returns:
9.37725*10^6
However, this only works for some points for Prism
and not for others. Other points generate a bunch of error messages. Input:
sample3D$edit2 =
BoundaryDiscretizeRegion@
Ellipsoid[{0, 0, 0}, {572, 96, 572}];
beam3D$edit2 = BoundaryDiscretizeRegion@
Prism[{{21824., 11.9101, -2810}, {6823.95, 38.09, -2810}, {-15000,
0, -2810}, {21824., 11.9101, 2810}, {6823.95, 38.09, 2810}, {-15000,
0, 2810}}];
Volume@RegionIntersection[beam3D$edit2, sample3D$edit2]
Returns error messages:
BoundaryDiscretizeRegion::regpnd: A non-degenerate region is expected at position 1 of BoundaryDiscretizeRegion[Prism[{{21824.,11.9101,-2810},{6823.95,38.09,-2810},{-15000,0,-2810},{21824.,11.9101,2810},{6823.95,38.09,2810},{-15000,0,2810}}]].
RegionIntersection::reg: BoundaryDiscretizeRegion[Prism[{{21824.,11.9101,-2810},{6823.95,38.09,-2810},{-15000,0,-2810},{21824.,11.9101,2810},{6823.95,38.09,2810},{-15000,0,2810}}]] is not a correctly specified region.
Volume::reg: RegionIntersection[BoundaryDiscretizeRegion[Prism[{{21824.,11.9101,-2810},{6823.95,38.09,-2810},{-15000,0,-2810},{21824.,11.9101,2810},{6823.95,38.09,2810},{-15000,0,2810}}]],] is not a correctly specified region.
Inspired by this answer I added Rationalize
to the Prisms points and this works for most of my applications, albeit rather slowly. Input:
sample3D$edit3 :=
BoundaryDiscretizeRegion@Ellipsoid[{0, 0, 0}, {572, 96, 572}];
beam3D$edit3 :=
BoundaryDiscretizeRegion@
Prism[Rationalize[{{150739.44950992631`,
23.691003428484592`, -2810}, {135739.44950992634`,
26.308997333058976`, -2810}, {-15000,
0, -2810}, {150739.44950992631`, 23.691003428484592`,
2810}, {135739.44950992634`, 26.308997333058976`,
2810}, {-15000, 0, 2810}}, 0]];
Volume@RegionIntersection[beam3D$edit3, sample3D$edit3] // AbsoluteTiming
Returns:
{11.139, 486462.}
Eventhough this works, it is too slow for my ultimate goal and still returns error messages for some points:
BoundaryMeshRegion::bsuncl: The boundary surface is not closed because the edges Line[{{763,315},{316,763},{315,316}}] only come from a single face.
Volume[MeshRegion[NDSolve
FEMToElementMesh[RegionIntersection[beam3D, sample3D]]]]
$\endgroup$DiscretizeRegion[beam3D]
also hangs on 13.0 which isn't great even if you just wanted an approximate result. Wolfram needs better QA for basic cases like this :( $\endgroup$