Everything You Ever Wanted to Know About Polygons and Polyhedra

Jaebum Jung, Yan Zhuang
Algorithms R&D, Wolfram Research

Join the Conversation #WolframTechConf

Outline of Talks - Polygon

Representation

Constructors

Predicates

Decompositions

Others

Representation - Polygon

Representation - Polygon

Representation - Polygon

Polygon[{{0.35, 0.2}, {0.9, 0.75}, {0.1, 0.55}, {0.9, 0.35}, {0.42, 0.9}}]

Representation - Polygon

Canonical Representation

Simple standard representation of a polygon

Enabling lower level programming or computation with polygons.

Also key to our own framework.

Representation - Polygon

CanonicalPolygon

converts a polygon to an optimized standard form.

Example 1

p1=Polygon[{{0,0},{1,1},{2,0}}]; p2=Polygon[{{2,0},{1,1},{0,0}}];

{cp1=CanonicalPolygon[p1],cp2=CanonicalPolygon[p2]}

InputForm[cp1]

InputForm[cp2]

Representation - Polygon

Example 2

p=Polygon[{{{0,0},{1.,0.},{0.5,1}},{{0.5,0.5},{1.5,0.5},{1.,1.5}}}]

Graphics[{EdgeForm[{Thickness[0.01],Red}],p}]

Representation - Polygon

Example 2

cp=CanonicalPolygon[Polygon[{{{0,0},{1.,0.},{0.5,1}},{{0.5,0.5},{1.5,0.5},{1.,1.5}}}]]

Graphics[{EdgeForm[{Thickness[0.01],Red}],cp}]

Representation - Polygon

Example 3

p=Polygon[{{0.35, 0.2}, {0.9, 0.75}, {0.1, 0.55}, {0.9, 0.35}, {0.42, 0.9}}]

cp=CanonicalPolygon[p]

%//InputForm

Graphics[{cp, Red, PointSize[.05],Point[PolygonCoordinates[p]]}]

Representation - Polygon

Polygon with holes

Polygon[ outer -> holes ]

Framed[Graphics[{Polygon[{{0,0},{1.,0.},{0.5,1}}], 
Thickness[.015],Arrowheads[.08],Arrow[{{1.2,.5},{1.8,.5}}],Red,Translate[Polygon[{{0.25,0.25},{0.75,0.25},{0.6,0.65},{0.4,0.65}}],{1.8,0}]}, ImageSize->500], RoundingRadius->10, FrameMargins->30]

Polygon[{{0,0},{1.,0.},{0.5,1}} -> {{{0.25,0.25},{0.75,0.25},{0.6,0.65},{0.4,0.65}}}]//Graphics

Representation - Polygon

Utility Functions

PolygonCoordinates

gives a list of coordinates in the polygon.

OuterPolygon

gives the outer polygon of the polygon.

InnerPolygon

gives the inner polygon of the polygon.

Representation - Polygon

PolygonCoordinates

OuterPolygon

InnerPolygon

Example

p=Polygon[{{0,0},{1.,0.},{0.5,1}} -> {{0.25,0.25},{0.75,0.25},{0.6,0.65},{0.4,0.65}}]

PolygonCoordinates[p]

OuterPolygon[p]

InnerPolygon[p]

Constructors - Polygon

CrossingPolygon

WindingPolygon

RandomPolygon

Constructors - Polygon

CrossingPolygon

A point is in (RefLink[CrossingPolygon, paclet:ref/CrossingPolygon]) if a ray starting at that point to infinity in any direction will cross the boundary curves an odd number of times. The number of ray crossings is given by (RefLink[CrossingCount, paclet:ref/CrossingCount]).

Constructors - Polygon

CrossingPolygon

Example 1:

CrossingPolygon[{{0,0},{1,0},{1,1}}]

%//Graphics

Example 2:

CrossingPolygon[{{0.35, 0.2}, {0.9, 0.75}, {0.1, 0.55}, {0.9, 0.35}, {0.42, 0.9}}]

%//Graphics

Example 3:

CrossingPolygon[]

%//Graphics

Constructors - Polygon

WindingPolygon

A point p is in the polygon if the number of revolutions of the closed contour around p is not zero. The number of revolutions is given by (RefLink[WindingCount, paclet:ref/WindingCount]).

Constructors - Polygon

WindingPolygon

Example 1:

WindingPolygon[{{0,0},{1,0},{1,1}}]

%//Graphics

Example 2:

WindingPolygon[{{0.35, 0.2}, {0.9, 0.75}, {0.1, 0.55}, {0.9, 0.35}, {0.42, 0.9}}]

%//Graphics

Example 3:

WindingPolygon[]

%//Graphics

Constructors - Polygon

CrossingPolygon vs WindingPolygon vs Polygon

Example 1:

Graphics/@Through[{Polygon, CrossingPolygon, WindingPolygon}[{{0,0},{1,0},{1,1}}]]

Example 2:

Graphics/@Through[{Polygon, CrossingPolygon, WindingPolygon}[{{0.35, 0.2}, {0.9, 0.75}, {0.1, 0.55}, {0.9, 0.35}, {0.42, 0.9}}]]

Example 3:

Graphics/@Through[{Polygon, CrossingPolygon, WindingPolygon}[]]

Constructors - Polygon

RandomPolygon

gives a pseudorandom polygon with the specified specification.

Constructors - Polygon

RandomPolygon

Example 1:

RandomPolygon[]

Example 2:

RandomPolygon["Convex", 3]

Example 3:

RandomPolygon["Simple", 3]

Example 4:

RandomPolygon[{"StarShaped", 10},3]

Predicates - Polygon

ConvexPolygonQ

gives (RefLink[True, paclet:ref/True]) if the polygon poly is convex, and (RefLink[False, paclet:ref/False]) otherwise.

Example 1:

RandomPolygon[]

ConvexPolygonQ[%]

Example 2:

RandomPolygon["Convex"]

ConvexPolygonQ[%]

Predicates - Polygon

SimplePolygonQ

gives (RefLink[True, paclet:ref/True]) if the polygon poly is simple and (RefLink[False, paclet:ref/False]) otherwise.

Example 1:

RandomPolygon[]

SimplePolygonQ[%]

Example 2:

Polygon[{{0.35, 0.2}, {0.9, 0.75}, {0.1, 0.55}, {0.9, 0.35}, {0.42, 0.9}}]

SimplePolygonQ[%]

Decompositions - Polygon

PolygonDecomposition

decomposes the polygon poly into a disjoint union of simpler polygons

Decompositions - Polygon

Example:

SeedRandom[123];p=RandomPolygon[18]

PolygonDecomposition[p, "Simple"]

PolygonDecomposition[p, "Convex"]

PolygonDecomposition[p, "Triangle"]

Motivation - Polyhedron

mr=RegionDifference[BoundaryDiscretizeRegion@Cuboid[],Cuboid[{0.25,0.25,0.25},{0.75,0.75,0.75}]];

Graphics3D[{Opacity[0.5],mr}]

MeshCells[mr,2]

MeshCells[mr,3]

Outlines of Talk - Polyhedron

Representation

Constructors

Operations

Decompositions

Others

Representation - Polyhedron

Representation - Polyhedron

Example:

p=Polyhedron[{{-0.5,-0.5,-0.5},{-0.5,-0.5,0.5},{-0.5,0.5,-0.5},{-0.5,0.5,0.5},{0.5,-0.5,-0.5},{0.5,-0.5,0.5},{0.5,0.5,-0.5},{0.5,0.5,0.5}}, {{8, 4, 2, 6}, {8, 6, 5, 7}, {8, 7, 3, 4}, {4, 3, 1, 2}, {1, 3, 7, 5}, {2, 1, 5, 6}}]

Graphics3D[p]

Graphics3D[GraphicsComplex[{{-0.5,-0.5,-0.5},{-0.5,-0.5,0.5},{-0.5,0.5,-0.5},{-0.5,0.5,0.5},{0.5,-0.5,-0.5},{0.5,-0.5,0.5},{0.5,0.5,-0.5},{0.5,0.5,0.5}},Polygon[{{8, 4, 2, 6}, {8, 6, 5, 7}, {8, 7, 3, 4}, {4, 3, 1, 2}, {1, 3, 7, 5}, {2, 1, 5, 6}}]]]

Representation - Platonic Solid

Representation - Polyhedron

Example:

UniformPolyhedron["GreatIcosidodecahedron"]

Region[%, PlotTheme->"Web", ImageSize->600]

Representation - Polyhedron

Canonical Representation

Simple standard representation of a polyheron

Enabling lower level programming or computation with polyhedrons.

Also key to our own framework.

Representation - Polyhedron

PolyhedronCoordinates

OuterPolyhedron

InnerPolyhedron

Example

p=;

PolyhedronCoordinates[p]

OuterPolyhedron[p]

InnerPolyhedron[p]

Constructors - Polyhedron

UniformPolyhedron

RandomPolyhedron

CrossingPolyhedron

WindingPolyhedron

Constructors - Uniform Polyhedron

Grid[Partition[Framed[Show[Region[UniformPolyhedron[#]],PlotLabel->#,ImageSize->{240,200}],RoundingRadius->10]&/@{{4,3},{5,3},{3,5},{3,4},"GreatDodecicosidodecahedron","GreatStellatedDodecahedron","Dodecadodecahedron","DitrigonalDodecadodecahedron","CubitruncatedCuboctahedron","GreatSnubIcosidodecahedron","SnubCube","SmallCubicuboctahedron"},4]]

Constructors - Random Polyhedron

Example:

Table[RandomPolyhedron[{"ConvexHull",n}],{n,10,120,15}];

Multicolumn[Region/@%,4]

Decomposition - Polyhedron

“Simple”

“Convex”

“Tetrahedron”

Example:

p =;

PolyhedronDecomposition[p]

Graphics3D[%]

Operations - Polyhedron

DualPolyhedron

TruncatedPolyhedron

AugmentedPolyhedron

SnubPolyhedron

BeveledPolyhedron

Operations - Dual Polyhedron

Example:

DualPolyhedron[Dodecahedron[]]

DualPolyhedron[]

DualPolyhedron[];

Graphics3D[%,Boxed-> False]

Operations -  Truncated Polyhedron

Example:

Table[Graphics3D[TruncatedPolyhedron[Dodecahedron[],l],Boxed->False],{l,{0.1,0.2,0.3,0.5}}]

Operations - Augmented Polyhedron

Example:

Multicolumn[Table[Row[{Graphics3D[f,Boxed-> False,ImageSize-> 100],,Graphics3D[AugmentedPolyhedron[f],Boxed-> False,ImageSize-> 100]}],{f,Most[PolyhedronData["Archimedean","BoundaryMeshRegion"]]}],3,Spacings->5]

Operations - Snub Polyhedron

Example:

Grid[Table[{Graphics3D[f[1],Boxed-> False],,Graphics3D[SnubPolyhedron[f[1]],Boxed-> False]},{f,{Tetrahedron,Hexahedron,Dodecahedron}}]]

Operations - Beveled Polyhedron

Example:

Grid[Table[{Graphics3D[f[1],Boxed-> False],,Graphics3D[BeveledPolyhedron[f[1]],Boxed-> False]},{f,{Tetrahedron,Hexahedron,Dodecahedron}}]]

Measures - Polyhedron Genus

Example:

;

PolyhedronGenus[%]

Learn More

Guide Pages

Polygons (General Overview) [product] [web]

Polyhedra (General Overview) [product] [web]

Geometric Computation (General Overview) [product] [web]

Plane Geometry (Special Overview) [product] [web]

Solid Geometry (Special Overview) [product] [web]

Region Properties & Measures [product] [web]

Solvers over Regions [product] [web]

3D Printing [product] [web]

Basic Geometric Regions [product] [web]

Mesh-Based Geometric Regions [product] [web]

Derived Geometric Regions [product] [web]