How to convert ImplicitRegion
to Line
, InfiniteLine
or HalfLine
?
I did it manually:
ir = ImplicitRegion[#, {x, y}] & /@ {{x <= 1/3 &&
y == -x}, {x == 1/3 && y <= -(1/3)}, {1/3 <= x <= 1/2 &&
y == -1 + 2 x}, {x <= 1/2 && y == 1 - 2 x}, {x >= 1/2 &&
y == 0}, {2 x + 3 y == 1}};
line = {HalfLine[{{1/3, -1/3}, {0, 0}}],
HalfLine[{{1/3, -1/3}, {1/3, -1}}], Line[{{1/3, -1/3}, {1/2, 0}}],
HalfLine[{{1/2, 0}, {0, 1}}], HalfLine[{{1/2, 0}, {1, 0}}],
InfiniteLine[{{0, 1/3}, {1, -1/3}}]};
RegionEqual @@@ Transpose[{ir, line}]
Show[Region[#, PlotRange -> 3] & /@ ir,
Graphics[{Dashed, line}, PlotRange -> 3]]
{True, True, True, True, True, True}
Notice that the third True
can be sometimes False
due to this bug in RegionEqual
but True
is the correct result.
Also notice that definition of HalfLine
or InfiniteLine
are not unique, I will accept any form.
There is also:
RegionConvert[HalfLine[{{1/3, -1/3}, {0, 0}}], "Implicit"]
ImplicitRegion[X + Y == 0 && X <= 2/3 + Y, {X, Y}]
But I think it only converts lines to implicit region but not the other way.