1 """Imago geometry module"""
4 def __init__(self, x, y):
8 def __add__(self, other):
9 return V(self.x + other.x, self.y + other.y)
11 def __sub__(self, other):
12 return V(self.x - other.x, self.y - other.y)
14 def __rmul__(self, other):
15 return V(other * self.x, other * self.y)
20 def __getitem__(self, key):
25 elif type(key) != int:
26 raise TypeError("V indices must be integers")
28 raise KeyError("V index ({}) out of range".format(key))
36 return V(-self.y, self.x)
38 def projection(point, line, vector):
39 return V(*intersection(g_line(point, point + vector.normal), g_line(*line)))