Function Repository Resource:

NotchedPolygon

Source Notebook

Represent a polygon with notched corners

Contributed by: Jan Mangaldan

ResourceFunction["NotchedPolygon"][{p1,,pn},r]

represents a filled notched polygon with points pi and notch radius r.

ResourceFunction["NotchedPolygon"][{p1,,pn},{r1,,rn}]

represents a filled notched polygon with points pi and corresponding notch radii ri.

Details

ResourceFunction["NotchedPolygon"] returns a Polygon object, and can be used as a graphics primitive.
ResourceFunction["NotchedPolygon"][poly,rspec], where poly is a Polygon, Rectangle or Triangle object, gives a notched version of poly.
The notch radii ri must be non-negative numbers.
ResourceFunction["NotchedPolygon"] works with 2D and 3D polygons.

Examples

Basic Examples (2) 

A triangle with notched corners:

In[1]:=
poly = ResourceFunction[
  "NotchedPolygon"][{{0., 0.}, {1., 0.}, {0., 1.}}, 0.1]
Out[1]=
In[2]:=
Graphics[{Pink, poly}]
Out[2]=

A rectangle with different notch radii for each corner:

In[3]:=
Graphics[{Pink, ResourceFunction["NotchedPolygon"][
   Rectangle[{0, 0}, {2, 1}], {0.2, 0.1, 0.2, 0.1}]}]
Out[3]=

Scope (4) 

Coordinates for a star-shaped polygon:

In[4]:=
star = N[Riffle[CirclePoints[{1, \[Pi]/10}, 5], RotateLeft@CirclePoints[{4 Sin[\[Pi]/10]^2, -\[Pi]/10}, 5]]];

Show the original polygon and the notched version:

In[5]:=
Row[Graphics /@ {{Blue, Polygon[star]}, {Yellow, ResourceFunction["NotchedPolygon"][Polygon[star], 0.1]}}]
Out[5]=

Use different notch radii for each vertex:

In[6]:=
Row[Graphics /@ {{Blue, Polygon[star]}, {Yellow, ResourceFunction["NotchedPolygon"][Polygon[star], PadRight[{}, 10, {1/10, 1/20}]]}}]
Out[6]=

A notched 3D polygon:

In[7]:=
Graphics3D[{FaceForm[Blue, Red], ResourceFunction["NotchedPolygon"][
   Polygon[PadRight[star, {Automatic, 3}]], PadRight[{}, 10, {1/10, 1/8}]]}]
Out[7]=

Applications (2) 

Plot a function over a notched polygon domain:

In[8]:=
Plot3D[Sin[6 x + Sin[6 y]]/6, {x, y} \[Element] ResourceFunction["NotchedPolygon"][N[CirclePoints[6]], 1/3], BoxRatios -> Automatic]
Out[8]=

A polyhedron with notched faces:

In[9]:=
facs = N[Flatten[Normal[PolyhedronData["DuerersSolid", "Faces"]]]];
In[10]:=
Graphics3D[{LightBlue, ResourceFunction["NotchedPolygon"][#, 1/5] & /@ facs}]
Out[10]=

Properties and Relations (1) 

NotchedPolygon returns a Polygon object:

In[11]:=
ResourceFunction["NotchedPolygon"][{{0., 0.}, {1., 0.}, {0., 1.}}, 0.1] // Head
Out[11]=

Possible Issues (2) 

If the notch radius is too large, NotchedPolygon may give unexpected results:

In[12]:=
Graphics[{Brown, ResourceFunction[
   "NotchedPolygon"][{{0., 0.}, {2., 0.}, {1.5, 1.}, {0.5, 1.}}, 0.6]}]
Out[12]=

Use a smaller notch radius:

In[13]:=
Graphics[{Brown, ResourceFunction[
   "NotchedPolygon"][{{0., 0.}, {2., 0.}, {1.5, 1.}, {0.5, 1.}}, 0.3]}]
Out[13]=

Neat Examples (1) 

Use NotchedPolygon with the resource function OutlinePolygons on a truncated icosahedron:

In[14]:=
tric = N[Flatten[
    Normal[PolyhedronData["TruncatedIcosahedron", "Faces"]]]];
In[15]:=
Graphics3D[{FaceForm[LightBlue], EdgeForm[], ResourceFunction["OutlinePolygons"][
   ResourceFunction["NotchedPolygon"][#, 1/5] & /@ tric]}, Boxed -> False]
Out[15]=

Version History

  • 1.0.0 – 04 February 2021

Related Resources

Author Notes

Polygons with holes are currently not supported.

License Information