from math import sqrt,sin,cos,tan,asin,acos,atan2,pi,floor def compare(x,y,ep): """ x,y の大小比較をする. ただし, ep の誤差は同一視する. [Input] x,y: float ep: float [Output] x>y: 1 x=y: 0 xep: return 1 elif x-y<-ep: return -1 else: return 0 class Point(): __slots__=["x","y","id"] ep=1e-9 def __init__(self,x=0,y=0): self.x=x self.y=y self.id=0 def sign(self,a): if a<-self.ep: return -1 elif a>self.ep: return 1 else: return 0 #文字列 def __str__(self): return "({}, {})".format(self.x,self.y) __repr__=__str__ #Bool def __bool__(self): return self.sign(self.x)!=0 or self.sign(self.y)!=0 #等号 def __eq__(self,other): return self.sign(self.x-other.x)==0 and self.sign(self.y-other.y)==0 #不等号 def __ne__(self,other): return not self==other #比較(<) def __lt__(self,other): T=self.sign(self.x-other.x) if T: return T<0 else: return self.sign(self.y-other.y)<0 #比較(<=) def __le__(self,other): return self) def __gt__(self,other): return other=) def __ge__(self,other): return other<=self #正と負 def __pos__(self): return self def __neg__(self): return Point(-self.x,-self.y) #加法 def __add__(self,other): return Point(self.x+other.x,self.y+other.y) #減法 def __sub__(self,other): return Point(self.x-other.x,self.y-other.y) #乗法 def __mul__(self,other): x,y=self.x,self.y u,v=other.x,other.y return Point(x*u-y*v,x*v+y*u) def __rmul__(self,other): if isinstance(other,(int,float)): return Point(other*self.x,other*self.y) #除法 def __truediv__(self,other): if other==0: raise ZeroDivisionError return Point(self.x/other,self.y/other) #絶対値 def __abs__(self): return sqrt(self.x*self.x+self.y*self.y) norm=__abs__ def norm_2(self): return self.x*self.x+self.y*self.y #回転 def rotate(self,theta): x,y=self.x,self.y s,c=sin(theta),cos(theta) return Point(c*x-s*y,s*x+c*y) def __iter__(self): yield self.x yield self.y def __hash__(self): return hash((self.x,self.y)) def latticization(self,delta=1e-7): if abs(self.x-floor(self.x+0.5))=0 """ assert Radius>=0 self.P=Center self.r=Radius self.id=4 def __str__(self): return "[Circle] Center: {}, Radius: {}".format(self.P,self.r) __repr__=__str__ def __contains__(self,P): return abs(abs(P-self.P)-self.r)