-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.py
More file actions
27 lines (19 loc) · 812 Bytes
/
point.py
File metadata and controls
27 lines (19 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
__author__ = 'Henry Vogt'
import vector
class Point(object):
def __init__(self,*coords):
self.coords = () # Koordinaten des Punkts in float Werten
for e in coords:
self.coords += (float(e),)
def getCoords(self):
return self.coords
def __repr__(self):
return 'Point%s' % (repr(self.coords))
def __add__(self, other): # Addition mit Vector
if isinstance(other, vector.Vector):
new_coords = tuple([x+y for (x,y) in zip(self.coords,other.getCoords())])
return Point(*new_coords)
def __sub__(self, other): # Subtraktion mit Point
if isinstance(other,Point):
new_coords = tuple([x-y for (x,y) in zip(self.coords,other.getCoords())])
return vector.Vector(*new_coords)