Files
@ 630c42e6d376
Branch filter:
Location: OneEye/src/analyzer/epoint.py - annotation
630c42e6d376
1.3 KiB
text/x-python
requirements.txt
3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 7ef3360afbe5 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 3798475f45c1 | import math
## Euclidean 2D plane point: (x,y).
class EPoint:
def __init__(self,x,y):
self.x=x
self.y=y
@staticmethod
def fromProjective(point):
if point.item(0)==0: return None
return EPoint(point.item(1)/point.item(0),point.item(2)/point.item(0))
def toProjective(self):
return (1,self.x,self.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 __sub__(self,a):
return EPoint(self.x-a.x,self.y-a.y)
def __mul__(self,k):
return EPoint(self.x*k,self.y*k)
def __rmul__(self,k):
return self*k
def __truediv__(self,k):
return EPoint(self.x/k,self.y/k)
def __floordiv__(self,k):
return EPoint(self.x//k,self.y//k)
def __iadd__(self,a):
self.x+=a.x
self.y+=a.y
return self
def __isub__(self,a):
self.x-=a.x
self.y-=a.y
return self
def __imul__(self,k):
self.x*=k
self.y*=k
return self
def __itruediv__(self,k):
self.x/=k
self.y/=k
return self
def __ifloordiv__(self,k):
self.x//=k
self.y//=k
return self
def __neg__(self):
return EPoint(-self.x,-self.y)
def __str__(self): return "({0},{1})".format(round(self.x,3),round(self.y,3))
def __repr__(self): return "EPoint({0},{1})".format(round(self.x,3),round(self.y,3))
|