RandomPolygon

RandomPolygon[n]

gives a pseudorandom simple polygon with n vertex points.

RandomPolygon[spec]

gives a pseudorandom polygon with the specified specification spec.

RandomPolygon[spec,k]

gives a list of k pseudorandom polygons.

RandomPolygon[dspec,]

gives a pseudorandom polygon in dimension d.

Details and Options

Examples

open allclose all

Basic Examples  (3)

Generate a random polygon:

Generate a list of random convex polygons:

Compute the area:

Generate a list of polygons in dimension 3:

Scope  (15)

Basic Uses  (6)

Generate a random polygon with a random number of vertex points:

Generate a random polygon with a given number of vertex points:

Generate a random polygon with a given number of vertex points in :

In :

Generate a list of polygons:

Generate multiple lists of polygons:

Generate a random polygon with a specified property:

Convex Polygons  (2)

Generate a random convex polygon:

Random convex polygon in :

In :

Convex Hull Polygons  (3)

Generate a random convex hull polygon:

Random convex hull polygon in :

In :

Generate a random convex hull polygon from the Dirichlet distribution:

Uniform distribution:

Normal distribution:

Binormal distribution:

Simple Polygons  (2)

Generate a random simple polygon:

Random simple polygon in :

In :

StarShaped Polygons  (2)

Generate a random star-shaped polygon:

Random star-shaped polygon in :

In :

Options  (8)

DataRange  (1)

DataRange allows you to specify the range of vertex points to generate:

Specify a different range:

WorkingPrecision  (1)

Generate a random polygon using machine arithmetic:

Using 30 digits of precision:

VertexColors  (2)

Generate a random polygon with vertex colors:

Specify vertex colors for 3D random polygons:

VertexNormals  (1)

Generate a random polygon; compute normal vectors using the cross product of edge vectors:

A triangle with normals:

Using different normals will affect shading:

VertexTextureCoordinates  (3)

Texture mapping with 2D random polygons:

Repeat a texture by using non-unified texture coordinate values:

Texture mapping is preceded by VertexColors:

Applications  (5)

Basic Uses  (2)

Random polygons with 10 vertex points:

Convex polygons:

Starshaped polygons:

Generate random polygons for testing algorithms and verification of time complexity:

Time complexity for algorithms for convex polygons:

Simple polygons:

Geometry Probability  (2)

Simulate random convex polygons and compute areas:

Estimate distribution:

Compare its histogram to the PDF:

Average area of polygons with 10 vertices over a unit square:

As goes to , the limit shape for random convex polygons is sqrt(1-TemplateBox[{x}, Abs])+sqrt(1-TemplateBox[{y}, Abs])=1:

Other Applications  (1)

Polygon classification using machine learning. Train a classifier function on polygon examples:

Use the classifier function to classify new polygons:

A simple polygon:

A starshaped polygon:

Properties & Relations  (5)

Use SeedRandom to get repeatable random polygons:

Use BlockRandom to block one use of RandomPolygon from affecting others:

Use ConvexPolygonQ to check the property of a random polygon:

SimplePolygonQ:

The OuterPolygon of a random polygon is simple:

Random polygons do not have holes:

Using PolygonDecomposition to decompose a polygon into convex polygons:

Neat Examples  (1)

Random polygon collections:

Wolfram Research (2019), RandomPolygon, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomPolygon.html.

Text

Wolfram Research (2019), RandomPolygon, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomPolygon.html.

CMS

Wolfram Language. 2019. "RandomPolygon." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomPolygon.html.

APA

Wolfram Language. (2019). RandomPolygon. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomPolygon.html

BibTeX

@misc{reference.wolfram_2024_randompolygon, author="Wolfram Research", title="{RandomPolygon}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/RandomPolygon.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_randompolygon, organization={Wolfram Research}, title={RandomPolygon}, year={2019}, url={https://reference.wolfram.com/language/ref/RandomPolygon.html}, note=[Accessed: 22-December-2024 ]}