This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Polygon

Polygon
is a graphics primitive that represents a filled polygon.
Polygon
represents a collection of polygons.
  • The positions of points can be specified either in ordinary coordinates as or , or in scaled coordinates as Scaled or Scaled. »
  • Offset can be used to specify coordinates in two dimensions. »
  • The boundary of a polygon is formed by joining the last point you specify to the first one.
  • FaceForm and EdgeForm can be used to specify how the interiors and boundaries of polygons should be rendered. »
  • In two dimensions, polygons are by default rendered with no explicit edges drawn. In three dimensions, they are by default rendered with black lines on their edges.
  • The option VertexColors can be used to specify different colors for each vertex of a polygon. The interior is then colored by interpolation between these. »
  • In three dimensions, shading of polygons is determined by simulated lighting.
  • Polygons are by default assumed to act like diffuse gray reflectors. Color directives can be used to change their surface color.
  • You can specify surface material properties using the graphics directives Specularity and Opacity.
  • Glow[color] can be used to add glow colors that are not affected by simulated illumination.
  • In three-dimensional graphics, polygons are considered to have both front and back faces, with their normals taken to point to the front.
  • You can use FaceForm to specify different properties for front and back faces. »
  • By default, the normal direction for a polygon is determined by a right-hand rule, so that typically the first three vertices will be in a counterclockwise order when viewed from the front.
  • The option VertexNormals can be used to specify effective normals at each vertex of a polygon, to be interpolated for purposes of smooth shading. »
  • Polygons in 2D and 3D can be non-convex, and can intersect themselves. Self-intersecting polygons are filled according to an even-odd rule that alternates between filling and not at each crossing.
  • In 3D, non-planar polygons are broken into triangles for rendering. Quadrilaterals are broken in two; other convex polygons are typically broken into triangles emanating from the center.
  • For purposes of shading, non-planar polygons are taken by default to have a single average normal.
  • Individual coordinates and lists of coordinates in polygons can be Dynamic objects.
Triangles:
Self-intersecting polygon:
Differently styled 2D polygons:
Differently styled 3D polygons:
Texture-mapped polygon:
Triangles:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
 
Self-intersecting polygon:
In[1]:=
Click for copyable input
Out[1]=
 
Differently styled 2D polygons:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
 
Differently styled 3D polygons:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
 
Texture-mapped polygon:
In[1]:=
Click for copyable input
Out[1]=
A collection of polygons:
Polygons with multiple vertices:
Color directives specify the face colors of polygons:
Texture can be used to specify a texture to be used on faces of polygons:
Texture can work together with different Opacity:
Texture can work together with different Lighting:
FaceForm and EdgeForm can be used to specify the styles of the interiors and boundaries:
In 3D, different properties can be specified for the front and back of faces using FaceForm:
Use FaceForm to set front and back textures differently in 3D:
Colors can be specified at vertices using VertexColors:
Normals can be specified at vertices using VertexNormals for 3D polygons:
Use Scaled coordinates:
Use ImageScaled coordinates in 2D:
Use Offset coordinates in 2D:
Polygon with vertex colors:
Specify vertex colors for 3D polygons:
Compute normal vectors using the cross product of edge vectors:
A triangle with normals pointing in the direction :
Using different normals will affect shading:
Texture mapping with 2D polygons:
Texture mapping with 3D polygons:
Repeat a texture by using non-unified texture coordinate values:
Texture mapping is preceded by VertexColors:
Define a polygon with vertices:
Regular polygons:
Star polygons:
Define the regular hexagon:
Regular hexagonal tiling:
Get face polygons from PolyhedronData:
Shrink each face with respect to the centroid:
GraphicsComplex offers an efficient way to generate a polygon with many shared vertices:
Applying Normal to the graphics complex produces ordinary polygons:
In 3D, if the vertices are not in a plane, the polygon triangulation can be unpredictable:
Seams can sometimes appear between individual polygons as a result of antialiasing:
Using a single polygon object avoids any seams:
Random triangle collections:
Digital petals:
A rotating star:
New in 1 | Last modified in 6