All pastes #450287 Raw Edit

Someone

public text v1 · immutable
·published 2007-04-20 18:55 UTC
rendered paste body
import math

def angle(r, n):
  return r*2*math.pi/n

def angular_eval(f, phi):
  return (f(phi)*math.cos(phi), f(phi)*math.sin(phi))

def angular_graph(f, count):
  return [angular_eval(f, angle(i, count)) for i in range(count)]



def circle(r):
  return lambda phi: r

def rose(n):
  return lambda phi: math.cos(n*phi) + 2

if __name__ == "__main__":
  tests = [angular_graph(circle(1), 20),
           angular_graph(rose(4), 20),
           angular_graph(rose(8), 200)]

  print len(tests)
  print
  
  for test in tests:
    print len(test)
    for p in test:
      print p[0], p[1]