Skip to content

Instantly share code, notes, and snippets.

@khafatech
Created June 2, 2009 20:20
Show Gist options
  • Save khafatech/122550 to your computer and use it in GitHub Desktop.
Save khafatech/122550 to your computer and use it in GitHub Desktop.
import math
radius = 105
width = (radius * 2) - 1
points = []
for x in xrange(-radius, radius+1):
for y in xrange(-radius, radius+1):
if math.sqrt(x**2 + y**2) < radius:
points.append((x,y))
print len(points)
polar_points = {}
for p in points:
# FIXME - fix angles and duplicates
if p[0] == 0:
# slope = 9000
theta = math.radians(90)
else:
# slope = float(p[1])/p[0]
theta = math.atan(float(p[1])/p[0])
if theta in polar_points:
polar_points[theta].append(p)
else:
polar_points[theta] = [p]
print len(polar_points)
# sorted polar points
spp = sorted(polar_points.items())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment