It is possible to generate a random Rectilinear Polygon (without holes) in WL? I found this option, but without any possibility to ask for a Rectilinear Polygon.
RandomPolygon["Convex", 2] It is possible to generate a random Rectilinear Polygon (without holes) in WL? I found this option, but without any possibility to ask for a Rectilinear Polygon.
RandomPolygon["Convex", 2] The number of vertices should be even and is given by 2 n below
RRPoly[n_] := Module[{x, y, indx, indy}, x = Accumulate[RandomReal[{-1, 1}, n]]; y = Accumulate[RandomReal[{-1, 1}, n]]; indx = Table[Quotient[i + 1, 2], {i, 2 n}]; indy = RotateLeft[indx]; Table[{x[[indx[[i]]]], y[[indy[[i]]]]}, {i, 2 n}] ] Generate 3 random polygons with random colors.
Graphics[{Opacity[0.9], Table[{RGBColor[RandomReal[{0, 1}, 3]], Polygon[RRPoly[5]]}, {k, 3}]}] ClearAll[rectilinearPoly] rectilinearPoly = Polygon@(Join @@ (Partition[#, 2, 1, 1] /. {{a_Real, b_}, {c_, d_}} :> {{a, b}, {c, b}, {c, d}})) &; Examples:
SeedRandom[1] coords = RandomReal[{-1, 1}, {5, 6, 2}]; Row[Graphics[{EdgeForm[Gray], FaceForm[Opacity[.5, RandomColor[]]], rectilinearPoly@#, Red, PointSize[Medium], Point@#}, ImageSize -> 1 -> 100]& /@ (#[[FindShortestTour[#][[2]]]] & /@ coords), Spacer[5]] Row[Graphics[{EdgeForm[Gray], FaceForm[Opacity[.5, RandomColor[]]], rectilinearPoly@#, Red, PointSize[Medium], Point@#}, ImageSize -> 1 -> 100] & /@ coords, Spacer[5]]