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

  • RandomPolygon gives a Polygon drawn from a specific distribution.
  • RandomPolygon is typically used in testing and verification of time complexity for algorithms.
  • Possible specifications spec include:
  • {"Convex",n}convex polygons with n vertex points
    {"Simple",n}simple polygons with n vertex points
    {"StarShaped",n}starshaped polygons with n vertex points
    {"ConvexHull",dist,n}convex hull of n random points from the distribution dist
  • RandomPolygon[] gives a pseudorandom simple polygon with the number of vertex points chosen in the range {3,15} with equal probability.
  • RandomPolygon[n] is equivalent to RandomPolygon[{"Simple",n}].
  • RandomPolygon[{"ConvexHull",n}] gives the convex hull of n random points from the uniform distribution UniformDistribution[2] over the unit square.
  • RandomPolygon[spec,{k1,k2,}] gives a k1×k2× array of pseudorandom polygons.
  • RandomPolygon gives a different sequence of pseudorandom polygons whenever you run the Wolfram Language. By using SeedRandom, you can get a repeatable sequence.
  • RandomPolygon has the same options as Polygon with the following additions:
  • DataRangeAutomaticthe range of vertex points to generate
    WorkingPrecisionMachinePrecisionprecision of vertex points
  • With the default setting DataRange Automatic, coordinates are chosen in the range 0 to 1.

Examples

open all close all

Basic Examples  (3)

Generate a random polygon:

In[14]:=
Click for copyable input
Out[14]=
In[15]:=
Click for copyable input
Out[15]=

Generate a list of random convex polygons:

In[1]:=
Click for copyable input
Out[1]=

Compute the area:

In[2]:=
Click for copyable input
Out[2]=

Generate a list of polygons in dimension 3:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Scope  (15)

Options  (8)

Applications  (5)

Properties & Relations  (5)

Neat Examples  (1)

Introduced in 2019
(12.0)