0
$\begingroup$

Each starry set has the following property:

pts0 = {{1, 0}, {2, 2.5}, {3, 0}, {2.5, 3.5}, {4, 5}, {2.5, 4.5}, 
        {2, 7}, {1.5, 4.5}, {0, 5}, {1.5, 3.5}, {1, 0}};
centroid = Mean[Drop[pts0, -1]];
pts = Table[k pts0 + ConstantArray[(1 - k) centroid, Length[pts0]], {k, 0, 1, 0.2}];
plots = Table[Graphics[{Red, Point[pts[[k]]], Blue, Line[pts[[k]]]}], {k, Length[pts]}];
Show[plots]

enter image description here

while if a set isn't starry, this geometric transformation doesn't work:

pts0 = {{1, 0}, {2, 0}, {2, 3}, {3, 3}, {3, 4}, {0, 4}, {0, 3}, {1, 3}, {1, 0}};
centroid = Mean[Drop[pts0, -1]];
pts = Table[k pts0 + ConstantArray[(1 - k) centroid, Length[pts0]], {k, 0, 1, 0.2}];
plots = Table[Graphics[{Red, Point[pts[[k]]], Blue, Line[pts[[k]]]}], {k, Length[pts]}];
Show[plots]

enter image description here

In the latter case, to get what you want, you can proceed manually:

pts0 = {{1, 0}, {2, 0}, {2, 3}, {3, 3}, {3, 4}, {0, 4}, {0, 3}, {1, 3}, {1, 0}};
offset = {{1, 1}, {-1, 1}, {-1, 1}, {-1, 1}, {-1, -1}, {1, -1}, {1, 1}, {1, 1}, {1, 1}};
pts = Table[pts0 + k offset, {k, 0, 0.5, 0.1}];
plots = Table[Graphics[{Red, Point[pts[[k]]], Blue, Line[pts[[k]]]}], {k, Length[pts]}];
Show[plots]

enter image description here

but I honestly can't see a way to generalize it.

So, I'm here to ask if there's a way to get the first and last graphic result via a single code, thanks!

$\endgroup$
0

1 Answer 1

1
$\begingroup$

It seems that there no general way.

pts0 = {{1, 0}, {2, 0}, {2, 3}, {3, 3}, {3, 4}, {0, 4}, {0, 3}, {1, 
    3}, {1, 0}};
reg = Polygon[pts0];
ContourPlot[SignedRegionDistance[reg, {x, y}], {x, -1, 4}, {y, -1, 4},
  Contours -> {0, -.1, -.2, -.3}, PlotPoints -> 40, MaxRecursion -> 2,
  ContourShading -> None]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.