Here is a more general method for producing polygons with rounded corners. Using a bit of vector algebra and trigonometry, I came up with the following:
arcgen[{p1_, p2_, p3_}, r_, n_] :=
Module[{dc = Normalize[p1 - p2] + Normalize[p3 - p2], cc, th},
cc = p2 + r dc/EuclideanDistance[dc, Projection[dc, p1 - p2]];
th = Sign[Det[PadRight[{p1, p2, p3}, {3, 3}, 1]]]
(π - VectorAngle[p3 - p2, p1 - p2])/(n - 1);
NestList[RotationTransform[th, cc],
p2 + Projection[cc - p2, p1 - p2], n - 1]]
roundedPolygon[Polygon[pts_?MatrixQ], r_?NumericQ, n : (_Integer?Positive) : 12] :=
Polygon[Flatten[arcgen[#, r, n] & /@
Partition[If[TrueQ[First[pts] == Last[pts]], Most, Identity][pts],
3, 1, {2, -2}], 1]]
Here, r
is the rounding radius. and n
controls the fineness of the component circle arcs. The resulting Polygon[]
can then be fed into BoundaryDiscretizeRegion[]
or DiscretizeRegion[]
if needed.
Here is the OP's original case:
DiscretizeRegion[roundedPolygon[Polygon[N[CirclePoints[{1, π/10}, 5], 20]], 1/5]]
A concave example:
star = N[Riffle[CirclePoints[{1, π/10}, 5],
RotateLeft @ CirclePoints[{4 Sin[π/10]^2, -π/10}, 5]], 20];
DiscretizeRegion[roundedPolygon[Polygon[star], 1/8]]
Use the rounded star as a domain:
Plot3D[Sin[6 x + Sin[6 y]], {x, y} ∈ roundedPolygon[Polygon[N[star, 20]], 1/8]]
Compare the result of roundedPolygon[]
with the built-in Rectangle[]
:
{Graphics[roundedPolygon[Polygon[{{0, 0}, {4, 0}, {4, 2}, {0, 2}} // N], 1/2],
Frame -> True],
Graphics[Rectangle[{0, 0}, {4, 2}, RoundingRadius -> 1/2], Frame -> True]} // GraphicsRow
As a final example demonstrating the flexibility of the routine, here is some Voronoi art:
BlockRandom[SeedRandom[42, Method -> "MersenneTwister"];
pts = RandomReal[{-2, 2}, {50, 2}]];
BlockRandom[SeedRandom[42, Method -> "ExtendedCA"];
Graphics[{Directive[ColorData[61, RandomInteger[{1, 9}]], EdgeForm[Gray]],
roundedPolygon[#, 1/8]} & /@ MeshPrimitives[VoronoiMesh[pts], 2]]]