Slide 41
Slide 41 text
import math
class PolarPoint(object):
x, y = 0, 0
def __init__(self, base_point):
if base_point:
x, y = base_point
def radius(self):
return math.sqrt(x**2 + y**2)
def angle(self):
return math.atan2(y, x)
points = [(3, 4), (5, 12)]
rev_points = [
(y, x) for x, y in points]
all_points = map(
PolarPoint,
points + rev_points + [None])
print [int(p.radius())
for p in all_points]
(a)[0, 0, 0, 0, 0]
(b)[5, 12, 5, 12, 0]
(c)[5, 13, 5, 13, 0]
(d)[13, 13, 13, 13, 13]