Files
@ 5f61b4d8cab9
Branch filter:
Location: OneEye/src/epoint.py - annotation
5f61b4d8cab9
1.5 KiB
text/x-python
proper Grid initialization
added special methods to EPoint
added Grid construction and presentation to GUI
added special methods to EPoint
added Grid construction and presentation to GUI
1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 1f1d49c1dbea 1f1d49c1dbea 1f1d49c1dbea 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 5f61b4d8cab9 | import math
## Euclidean 2D plane point: (x,y).
class EPoint:
def __init__(self,x,y):
self.x=x
self.y=y
def fromTuple(tup): return EPoint(tup[0],tup[1])
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))
|