TransWikia.com

On the geometric transformations of polygons

Mathematica Asked by Monster on August 17, 2021

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!

One Answer

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

Correct answer by cvgmt on August 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP