I don't think there's a built in "RegionSimplify
" for polyhedral Regions and derived akin to how Interval automatically simplifies its argument expression:
Interval[{0, 1}, {1, 2}]
and
Interval[{0, 1}]~IntervalUnion~Interval[{1, 2}]
yield
Interval[{0, 2}]
In contrast, RegionUnion
remains unevaluated, even in 2D:
Line[{{0, 0}, {1, 0}}]~ RegionUnion ~ Line[{{1, 0}, {2, 0}}]
(* RegionUnion[Line[{{0, 0}, {1, 0}}], Line[{{1, 0}, {2, 0}}]] *)
From
Rectangle[{0, 0}, {1, 1}] ~ RegionUnion ~
Rectangle[{1, 0}, {2, 1}] // RegionBoundary // DiscretizeRegion
As expected, the Rectangles
' common segment is not part of the output.
How to expose or compute the ideal normal form for 2D (at least) polyhedral Regions like these basic examples:
Overlapping lines:
Line[{{0, 0}, {2, 0}}]~ RegionUnion ~ Line[{{1, 0}, {3, 0}}] (* // RegionSimplify *)
(* Line[{{0,0},{3,0}}] *)
Union of rectangles:
Rectangle[{0, 0}, {1, 1}] ~ RegionUnion ~
Rectangle[{1, 0}, {2, 1}] (* // RegionSimplify *)
(* Rectangle[{0, 0}, {2, 1}] *)
Boundary:
Rectangle[{0, 0}, {1, 1}] ~ RegionUnion ~
Rectangle[{1, 0}, {2, 1}] // RegionBoundary (* // RegionSimplify *)
(* Line[{{0,0},{2,0},{2,1},{0,1},{0,0}}] *)
The simplification should work for all 2D polyhedral regions including cones (which btw the current language does not support correctly):
ConicHullRegion[{{0, 0}}, {{1, 0}, {1, 1}}] ~RegionUnion ~
ConicHullRegion[{{0, 0}}, {{0, 1}, {1, 1}}] (* // RegionSimplify *)
(* ConicHullRegion[{{0, 0}}, {{1, 0}, {0, 1}}] *)
For convex regions and convex-preserving operations (eg intersection) should suffice to consider the extreme set (vertices and rays), but in general regions aren't convex (and union doens't preserve it).
(Note: RegionIntersection
of the same Rectangles
hangs the kernel w/ msg: Last::nolast: "{} has a length of zero and no last element"
)
Comments
Post a Comment