import sys; sys.path.insert(0,"."); sys.path.insert(0,"pylib") import pickle, collections, swdots, math, numpy as np, io segs,texts=pickle.load(open('cache_옥성교P1.dxf.pkl','rb')); swdots.segs=segs o=io.open('okcol4.txt','w',encoding='utf-8') def fit(pts): A=np.array([[2*x,2*y,1] for x,y in pts]); b=np.array([x*x+y*y for x,y in pts]) s=np.linalg.lstsq(A,b,rcond=None)[0]; cx,cy=s[0],s[1]; return cx,cy,math.sqrt(s[2]+cx*cx+cy*cy) for nm,(cx0,cy0) in {'C-C':(624030,335430),'D-D':(631600,335430),'E-E':(639490,335430),'F-F':(608700,322950)}.items(): D=swdots.dots(cx0-1700,cx0+1700,cy0-1700,cy0+1700,maxlen=60) sz=collections.Counter((d[2],d[3]) for d in D); o.write(u'%s dots %s\n'%(nm,sz.most_common(6))) P=[(d[0],d[1]) for d in D if d[2]==22.5 and d[3]==22.5] if len(P)>10: cx,cy,r=fit(P); rr=[math.hypot(x-cx,y-cy) for x,y in P] o.write(u' 22.5점 %d개 중심 (%.1f,%.1f) r %.1f (min %.1f max %.1f)\n'%(len(P),cx,cy,r,min(rr),max(rr))) c=collections.Counter(round(v/10)*10 for v in rr); o.write(u' 군집 %s\n'%sorted(c.items()))