Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Table[Polygon@Map[{Cos[#], Sin[#]} &,
- {RandomReal[{0, 2 Pi/3}],
- RandomReal[{2 Pi/3, 4 Pi/3}],
- RandomReal[{4 Pi/3, 2 Pi}]}], 3]
- Graphics[{EdgeForm[Black], White, %}]
- {Polygon[{{-0.334165, 0.942514}, {-0.67166, 0.740859}, {-0.455064, -0.890459}}],
- Polygon[{{0.274586, 0.961563}, {-0.99882, -0.0485668}, {-0.454045, -0.890979}}],
- Polygon[{{0.832368, 0.554224}, {-0.977216, -0.212246}, {0.451922, -0.892057}}]}
- Table[triregion[i] = BoundaryDiscretizeGraphics[Graphics[triangles[[i]]]],
- {i, 1, Length[triangles]}]
- layerorder = {3, 2, 1}
- intersections = Flatten[
- Table[If[Length[
- RegionIntersection[
- triregion[layerorder[[i]]],
- triregion[layerorder[[j]]]]
- ] == 0, {layerorder[[i]], layerorder[[j]]}, Nothing],
- {i, 1, 3}, {j, i + 1, 3}], 1]
- Out: {{3, 2}, {3, 1}, {2, 1}}
- Table[newregion[i] = triregion[i], {i, 20}];
- Map[(newregion[#[[2]]] = RegionDifference[newregion[#[[2]]], triregion[#[[1]]]]) &,
- intersections];
- boundaries = Map[MeshPrimitives[#, 1] &, {newregion[1], newregion[2], newregion[3]}];
- Show[Graphics /@ boundaries]
- d1 = {{-0.334165,0.942514},{-0.67166,0.740859},{-0.455064,-0.890459}};
- d2 = {{0.274586,0.961563},{-0.99882,-0.0485668},{-0.454045,-0.890979}};
- d3 = {{0.832368,0.554224},{-0.977216,-0.212246},{0.451922,-0.892057}};
- t1 = Line[Append[d1, First@d1]];
- t2 = Line[Append[d2, First@d2]];
- t3 = Line[Append[d3, First@d3]];
- p1 = Polygon[d1];
- p2 = Polygon[d2];
- p3 = Polygon[d3];
- r1 = t3;
- r2 = RegionDifference[t2, p3];
- r3 = RegionDifference[t1, RegionUnion[p2, p3]];
- DiscretizeRegion @ RegionUnion[r1, r2, r3]
- RegionUnion[r1, r2, r3]
- Region@RegionUnion[
- Polygon[{{-0.334165, 0.942514}, {-0.67166, 0.740859}, {-0.455064, -0.890459}}],
- Polygon[{{0.274586, 0.961563}, {-0.99882, -0.0485668}, {-0.454045, 0.890979}}],
- Polygon[{{0.832368, 0.554224}, {-0.977216, -0.212246}, {0.451922, -0.892057}}]
- ]
- In[1]:= pols=Table[Polygon@Map[{Cos[#], Sin[#]} &, {RandomReal[{0, 2 Pi/3}],
- RandomReal[{2 Pi/3, 4 Pi/3}], RandomReal[{4 Pi/3, 2 Pi}]}], 3];
- In[2]:= Graphics[{EdgeForm[Black], White, pols}];
- In[3]:= DiscretizeGraphics@%;
- In[4]:= Graphics@MeshPrimitives[%, 1];
- In[5]:= reg=DiscretizeGraphics@%
- In[6]:= RegionDimension@reg
- Out[16]= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement