Skip to main content
use coordinate tuples; allow to work for Python 3
Source Link
Mike T
  • 42.4k
  • 10
  • 129
  • 190

Here's a solution for the trigonometry in Python (credit to my wife, who pointed out the problem was an ellipse, not a circle):

# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x(x,y] y))

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)

Which generates a shape which looks like: enter image description here

Incorporating the math in an arcpy script to copy a point featureclass to polygon is left as an exercise.

Here's a solution for the trigonometry in Python (credit to my wife, who pointed out the problem was an ellipse, not a circle):

# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)

Which generates a shape which looks like: enter image description here

Incorporating the math in an arcpy script to copy a point featureclass to polygon is left as an exercise.

Here's a solution for the trigonometry in Python (credit to my wife, who pointed out the problem was an ellipse, not a circle):

# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append((x, y))

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print(coords)

Which generates a shape which looks like: enter image description here

Incorporating the math in an arcpy script to copy a point featureclass to polygon is left as an exercise.

deleted 6 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Edit: Here's a solution for the trigonometry in Python (credit to my wife, who pointed out the problem was an ellipse, not a circle):

# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)

Which generates a shape which looks like: enter image description here

Incorporating the math in an arcpy script to copy a point featureclass to polygon is left as an exercise.

Edit: Here's a solution for the trigonometry in Python (credit to my wife, who pointed out the problem was an ellipse, not a circle):

# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)

Which generates a shape which looks like: enter image description here

Incorporating the math in an arcpy script to copy a point featureclass to polygon is left as an exercise.

Here's a solution for the trigonometry in Python (credit to my wife, who pointed out the problem was an ellipse, not a circle):

# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)

Which generates a shape which looks like: enter image description here

Incorporating the math in an arcpy script to copy a point featureclass to polygon is left as an exercise.

Added language tag
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84
# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)
# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)
# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)
# FunkyEllipse.py

import math

n_dist=5000
e_dist=2000
s_dist=1500
w_dist=1000

distV=[n_dist,e_dist,s_dist,w_dist,n_dist]
radix=0

nverts=120              #!! Must be evenly divisible by 4!
quad=nverts / 4

step=(math.pi * 2) / nverts
stepSin = math.sin(step);
stepCos = math.cos(step);

acc1   = 1.0            # Cos(90)
acc2   = 0.0            # Sin(90)
coords = []
for i in range(0,nverts):
    if ((radix % 2) == 0):
        x = acc2 * distV[(radix+1)%4]
        y = acc1 * distV[radix%4]
    else:
        x = acc2 * distV[radix%4]
        y = acc1 * distV[(radix+1)%4]

    coords.append([x,y])

    if ((i % quad) == (quad - 1)):
        radix += 1

    temp = (acc1 * stepCos) - (acc2 * stepSin)
    acc2 = (acc2 * stepCos) + (acc1 * stepSin)
    acc1 = temp

coords.append(coords[0])
print str(coords)
Revised code to fit desired form (pseudo-ellipse)
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
Loading
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65
Loading