Quantcast
Channel: How do I properly define and work with region unions? - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 2

How do I properly define and work with region unions?

$
0
0

Suppose I have two regions defined by two hexahedrons (slightly adapted from this question):

hexpts = {{1.7, 1.5, 0}, {1.7, 10.8, 0}, {20.3, 10.8, 0.01}, {20.3,     1.5, 0}, {1.7, 1.5, 0.6}, {1.7, 10.8, 0.6}, {20.3, 10.8,     0.6}, {20.3, 1.5, 0.6}};reg = Hexahedron[Rationalize[hexpts]];hexpts2 = {{1.7, 1.5, 0}, {1.7, 10.8, 0}, {20.3, 10.8, 0.01}, {20.3,      1.5, 0}, {1.7, 1.5, 0.6}, {1.7, 10.8, 0.6}, {20.3, 10.8,      0.6}, {20.3, 1.5, 0.6}} + 0.1;reg2 = Hexahedron[Rationalize[hexpts2]];Region@reg

enter image description here

Now I am interested in the RegionUnion of both:

myreg = RegionUnion[reg, reg2]Region@myreg 

enter image description here

Then all 3 regions are Regions and also bounded regions:

list = {reg, reg2, myreg};RegionQ[#] & /@ listBoundedRegionQ[#] & /@ list

{True, True, True}

{True, True, True}

But I cannot calculate the volume nor other region parameters for the region union:

Volume[#] & /@ list

{103.211, 103.211,Volume[BooleanRegion[#1 || #2 &, {Hexahedron[{{17/10, 3/2, 0}, {17/10, 54/5, 0}, {203/10, 54/5, 1/100}, {203/10, 3/2, 0}, {17/10,3/2, 3/5}, {17/10, 54/5, 3/5}, {203/10, 54/5, 3/5}, {203/10, 3/2, 3/5}}],Hexahedron[{{9/5, 8/5, 1/10}, {9/5, 109/10, 1/10}, {102/5, 109/10,11/100}, {102/5, 8/5, 1/10}, {9/5, 8/5, 7/10}, {9/5, 109/10,7/10}, {102/5, 109/10, 7/10}, {102/5, 8/5, 7/10}}]}]]}

I tried discretizing the region union but it failed with:

 DiscretizeRegion@myreg

DiscretizeRegion::regpnd: A non-degenerate region is expected at position 1 of DiscretizeRegion[BooleanRegion[#1||#2&,{Hexahedron[{{17/10,3/2,0},{17/10,54/5,0},{203/10,54/5,1/100},{203/10,3/2,0},{17/10,3/2,3/5},{17/10,54/5,3/5},{203/10,54/5,3/5},{203/10,3/2,3/5}}],Hexahedron[{{9/5,8/5,1/10},{9/5,109/10,1/10},{102/5,109/10,11/100},{102/5,8/5,1/10},{9/5,8/5,7/10},{9/5,109/10,7/10},{102/5,109/10,7/10},{102/5,8/5,7/10}}]}]].

An error message that was raised in this question but the proposed solution (using Rationalize) isn't applicable for general Hexahedrons as it seems (note that I changed 0 to 0.01 in hexpts[[3,3]])

How do I properly define the RegionUnion of reg and reg2 so I can use Volume, RegionCentroid etc on it?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images