There are at least a few non-overlapping triangles made by the lines in the following graphic, how would I isolate them?
pts = RandomReal[1, {7, 2, 2}];
g = Graphics[{InfiniteLine @@@ pts}, Frame -> True,
PlotRange -> {{-1, 2}, {-1, 3}}]
Update:
Jason B gave a nice answer, but it needs it to work with both Line[]
and InfiniteLine[]
, for which the triangles[]
function below doesn't work:
SeedRandom[4430];
pts = RandomReal[1, {3, 2, 2}];
l = InfiniteLine @@@ pts; h =
Line@{{{0, 0}, {0, 2}}, {{0, 1}, {1, 1}}, {{1, 0}, {1, 2}}};
lines = Join[l, {h}];
g = Graphics[{lines, LightBlue, Triangle /@ triangles[lines]},
Frame -> True, PlotRange -> All, AspectRatio -> 1]