diff --git a/src/epoint.py b/src/epoint.py new file mode 100644 --- /dev/null +++ b/src/epoint.py @@ -0,0 +1,20 @@ +import math + + +## Euclidean 2D plane point: (x,y). +class EPoint: + def __init__(self,x,y): + self.x=x + self.y=y + + def dist(self,a): + return math.sqrt((self.x-a.x)**2+(self.y-a.y)**2) + + def __add__(self,a): + return EPoint(self.x+a.x,self.y+a.y) + + def __truediv__(self,k): + return EPoint(self.x/k,self.y/k) + + def __str__(self): return "({0},{1})".format(self.x,self.y) + def __repr__(self): return "EPoint({0},{1})".format(self.x,self.y)