Function Repository Resource:

RandomZonogon

Source Notebook

Generate random zonogons

Contributed by: Sander Huisman

ResourceFunction["RandomZonogon"][n]

gives a random zonogon with n sides where n should be even.

ResourceFunction["RandomZonogon"][{n,m}]

gives a random zonogon with between n and m sides.

ResourceFunction["RandomZonogon"][n,{min, max}]

gives a random zonogon with n sides and side lengths beteen min and max.

ResourceFunction["RandomZonogon"][n,{min, max},{n1,n2,n3,}]

gives an n1n2n3 array of random zonogons.

Details

A zonogon is a centrally-symmetric convex polygon. A zonogon therefore has pairs of lines that are parallel.
A zonogon has an even number of sides, n and m should therefore be even.
The default values for min and max are 0.5 and 1, respectively.

Examples

Basic Examples (2) 

Create a random zonogon with 6 sides:

In[1]:=
zgon = ResourceFunction["RandomZonogon"][6]
Out[1]=

Visualize it:

In[2]:=
Graphics[zgon]
Out[2]=

Create an 8-sided zonogon with side lengths between 4 and 10:

In[3]:=
ResourceFunction["RandomZonogon"][8, {4, 10}] // Graphics
Out[3]=

Scope (1) 

Create a 2⨯4 array of random zonogons with number of sides between 4 and 20 with side lengths between 0 and 1:

In[4]:=
ResourceFunction["RandomZonogon"][{4, 20}, {0, 1}, {2, 4}]
Out[4]=

Applications (2) 

Create a random parallelogram:

In[5]:=
ResourceFunction["RandomZonogon"][4, {0, 1}] // Graphics
Out[5]=

Create a random rhombus:

In[6]:=
ResourceFunction["RandomZonogon"][4, {1, 1}] // Graphics
Out[6]=

Possible Issues (2) 

If n (or m) are odd, the function will stay unevaluated:

In[7]:=
ResourceFunction["RandomZonogon"][5]
Out[7]=
In[8]:=
ResourceFunction["RandomZonogon"][{4, 9}]
Out[8]=

With a negative side lengths the polygon is generally not convex:

In[9]:=
ResourceFunction["RandomZonogon"][20, {-5, 5}] // Graphics
Out[9]=

Neat Examples (1) 

Make a scribbly tornado:

In[10]:=
Graphics[{FaceForm[], EdgeForm[Black], Table[ResourceFunction["RandomZonogon"][30, {i, i + 1}], {i, 1, 50}], Axes -> True}]
Out[10]=

Publisher

SHuisman

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 22 May 2024

Related Resources

License Information