Skip to content

Instantly share code, notes, and snippets.

View jmenashe's full-sized avatar

J jmenashe

  • San Francisco, CA
View GitHub Profile
@jmenashe
jmenashe / generate_random_polygon_vertices.py
Created February 9, 2018 20:26
Generates a set of vertices to create a randomized polygon.
# This source code was obtained from StackOverflow user "mike-ounsworth"
# Author Profile: https://stackoverflow.com/users/1907046/mike-ounsworth
# Original Source: https://stackoverflow.com/questions/8997099/algorithm-to-generate-random-2d-polygon/25276331#25276331
import math, random
def generatePolygon( ctrX, ctrY, aveRadius, irregularity, spikeyness, numVerts ) :
'''Start with the centre of the polygon at ctrX, ctrY,
then creates the polygon by sampling points on a circle around the centre.
Randon noise is added by varying the angular spacing between sequential points,