diff --git a/main.py b/main.py index 2ef4987..b780f44 100644 --- a/main.py +++ b/main.py @@ -135,7 +135,7 @@ class Cross(): # check whether a cross at pos interacts with cross def check_interaction(self,pos): - return int((pos.x-self.pos.x)/self.size)**2+int((pos.y-self.pos.y)/self.size)**2>=5 + return ((pos-self.pos)/self.size).int()**2>=5 # find position along a line that comes in contact with the line #def move_on_line_to_stick(self,x,v): @@ -148,9 +148,31 @@ class Point: def __add__(self,point): return Point(self.x+point.x,self.y+point.y) - def __neg__(self): - return Point(-self.x,self.y) + def __sub__(self,point): + return Point(self.x-point.x,self.y-point.y) + def __neg__(self): + return Point(-self.x,-self.y) + + def __mul__(self,a): + return Point(a*self.x,a*self.y) + + def __truediv__(self,a): + return Point(self.x/a,self.y/a) + + def __pow__(self,a): + if a==2: + return self.dot(self) + + # dot product + def dot(self,x): + return self.x*x.x+self.y*x.y + + # integer part + def int(self): + return Point(int(self.x),int(self.y)) + + # set position def setpos(self,x,y): self.x=x self.y=y