def chunk(b,epsilon,lscl = 1.0,j1 = None,j2 = None,edge = False): if j1 is None:j1 = random.randint(0,len(b)-1) if j2 is None:j2 = j1-1 l = b[j1].d(b[j2])*lscl t = random.uniform(0,2.0*numpy.pi) n = random.randint(3,8) if edge: stamp = b[j1].mid(b[j2]).pring(l/2.0,n) else: stamp = vec3( random.randint(int(l/4),int(l)), random.randint(int(l/4),int(l)), 0).com(b).pring(l/2.0,n) q = quat(1,0,0,0).av(t,vec3(0,0,1)) q.rotps(stamp) if pym.binbxy(stamp,b): return stamp elif pym.bintbxy(b,stamp,col = False,ie = False): nbs = pym.ebixy(b,stamp,epsilon) nbas = [pym.bareaxy(nb) for nb in nbs] nb = nbs[nbas.index(max(nbas))] nb = pym.aggregate(nb,1) if pym.bvalidxy(nb) > 0: return nb else: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b,ax,col = 'r',lw = 2) ax = dtl.plot_polygon_xy(stamp,ax,col = 'b',lw = 2) plt.show() raise ValueError
def pl(b1, b2, br): ax = dtl.plot_axes_xy(20) ax = dtl.plot_polygon_xy(b1, ax, col='b', lw=5.0) ax = dtl.plot_polygon_xy(b2, ax, col='g', lw=5.0) for b in br: ax = dtl.plot_polygon_xy(b, ax, col='r', lw=2.0) plt.show()
def ajagged(b,epsilon): j = random.randint(0,len(b)-1) l = b[j-1].d(b[j]) t = random.uniform(0,2.0*numpy.pi) n = random.randint(3,8) stamp = b[j-1].mid(b[j]).pring(l/2.0,n) q = quat(1,0,0,0).av(t,vec3(0,0,1)) q.rotps(stamp) if pym.bintbxy(b,stamp,col = False,ie = False): nbs = pym.ebdxy(b,stamp,epsilon) nbas = [pym.bareaxy(nb) for nb in nbs] nb = nbs[nbas.index(max(nbas))] nb = pym.aggregate(nb,1) if pym.bvalidxy(nb) > 0:b = nb bval = pym.bvalidxy(b) if bval == -1:b.reverse() if not pym.bvalidxy(b) > 0: ax = dtl.plot_axes_xy(700) ax = dtl.plot_polygon_xy(b,ax,lw = 4,col = 'b') ax = dtl.plot_points_xy(b,ax,number = True) ax = dtl.plot_polygon_xy(stamp,ax,lw = 2,col = 'r') plt.show() #pdb.set_trace() raise ValueError return b
def plotxy(self, ax=None): scale = vec3(1, 0, 0).prjps(self.footprint) scale = scale[1] - scale[0] if ax is None: ax = dtl.plot_axes_xy(scale) for vx in range(self.vcnt): v = self.vs[vx] if v is None: continue vb = v[1]['fp'] vrtls = '-' if 'developed' in v[1]['type'] else '--' #vrtls = '--' if 'natural' in v[1]['type'] else '-' ax = dtl.plot_polygon_xy(pym.contract(vb, 0.01 * scale), ax, lw=2, ls=vrtls, col=None) vbc = vec3(0, 0, 0).com(vb) rs = str(vx) + ',' + str(v[1]['edges']) + ',\n' + str(v[1]['type']) ax = dtl.plot_point_xy_annotate(vbc, ax, rs) for ve in v[1]['edges']: if self.vs[ve] is None: continue ovbc = vec3(0, 0, 0).com(self.vs[ve][1]['fp']) ax = dtl.plot_edges_xy((vbc, ovbc), ax, lw=3, col='c') for ep in v[1]['exits']: ax = dtl.plot_point_xy(ep, ax, mk='s', col='r') ax = dtl.plot_polygon_xy(self.footprint, ax, lw=1, col='g') return ax
def plotxy(self,fp = None,ax = None): if ax is None:ax = dtl.plot_axes_xy(50) for rmv in self.vs: if rmv is None:continue if rmv[2]['level'] > 0:continue bcol = 'b' if rmv[2]['shaft'] else None rconbs = 0.5 if pym.bccw(rmv[2]['bound']) else -0.5 rconb = pym.contract(rmv[2]['bound'],rconbs) ax = dtl.plot_polygon_xy(rconb,ax,lw = 4,col = bcol) rc = vec3(0,0,0).com(rmv[2]['bound']) rs = str(rmv[0])+','+str(rmv[1]) ax = dtl.plot_point_xy(rc,dtl.plot_point_xy_annotate(rc,ax,rs)) if rmv[1]: for re in rmv[1]: if self.vs[re] is None:continue rt = (rc,vec3(0,0,0).com(self.vs[re][2]['bound'])) ax = dtl.plot_edges_xy(rt,ax,col = 'g') for exit in rmv[2]['exits']: if exit is True: exitp = rc ax = dtl.plot_point_xy(exitp, dtl.plot_point_xy_annotate(exitp,ax,'exit')) else: ax = dtl.plot_point_xy(exit, dtl.plot_point_xy_annotate(exit,ax,'exit')) if not fp is None: ax = dtl.plot_polygon_xy(fp,ax,lw = 2,col = 'r') return ax
def ajagged(b, epsilon): j = random.randint(0, len(b) - 1) l = b[j - 1].d(b[j]) t = random.uniform(0, 2.0 * numpy.pi) n = random.randint(3, 8) stamp = b[j - 1].mid(b[j]).pring(l / 2.0, n) q = quat(1, 0, 0, 0).av(t, vec3(0, 0, 1)) q.rotps(stamp) if pym.bintbxy(b, stamp, col=False, ie=False): nbs = pym.ebdxy(b, stamp, epsilon) nbas = [pym.bareaxy(nb) for nb in nbs] nb = nbs[nbas.index(max(nbas))] nb = pym.aggregate(nb, 1) if pym.bvalidxy(nb) > 0: b = nb bval = pym.bvalidxy(b) if bval == -1: b.reverse() if not pym.bvalidxy(b) > 0: ax = dtl.plot_axes_xy(700) ax = dtl.plot_polygon_xy(b, ax, lw=4, col='b') ax = dtl.plot_points_xy(b, ax, number=True) ax = dtl.plot_polygon_xy(stamp, ax, lw=2, col='r') plt.show() #pdb.set_trace() raise ValueError return b
def plotxy(self, fp=None, ax=None): if ax is None: ax = dtl.plot_axes_xy(50) for rmv in self.vs: if rmv is None: continue if rmv[2]['level'] > 0: continue bcol = 'b' if rmv[2]['shaft'] else None rconbs = 0.5 if pym.bccw(rmv[2]['bound']) else -0.5 rconb = pym.contract(rmv[2]['bound'], rconbs) ax = dtl.plot_polygon_xy(rconb, ax, lw=4, col=bcol) rc = vec3(0, 0, 0).com(rmv[2]['bound']) rs = str(rmv[0]) + ',' + str(rmv[1]) ax = dtl.plot_point_xy(rc, dtl.plot_point_xy_annotate(rc, ax, rs)) if rmv[1]: for re in rmv[1]: if self.vs[re] is None: continue rt = (rc, vec3(0, 0, 0).com(self.vs[re][2]['bound'])) ax = dtl.plot_edges_xy(rt, ax, col='g') for exit in rmv[2]['exits']: if exit is True: exitp = rc ax = dtl.plot_point_xy( exitp, dtl.plot_point_xy_annotate(exitp, ax, 'exit')) else: ax = dtl.plot_point_xy( exit, dtl.plot_point_xy_annotate(exit, ax, 'exit')) if not fp is None: ax = dtl.plot_polygon_xy(fp, ax, lw=2, col='r') return ax
def chunk(b, epsilon, lscl=1.0, j1=None, j2=None, edge=False): if j1 is None: j1 = random.randint(0, len(b) - 1) if j2 is None: j2 = j1 - 1 l = b[j1].d(b[j2]) * lscl t = random.uniform(0, 2.0 * numpy.pi) n = random.randint(3, 8) if edge: stamp = b[j1].mid(b[j2]).pring(l / 2.0, n) else: stamp = vec3(random.randint(int(l / 4), int(l)), random.randint(int(l / 4), int(l)), 0).com(b).pring(l / 2.0, n) q = quat(1, 0, 0, 0).av(t, vec3(0, 0, 1)) q.rotps(stamp) if pym.binbxy(stamp, b): return stamp elif pym.bintbxy(b, stamp, col=False, ie=False): nbs = pym.ebixy(b, stamp, epsilon) nbas = [pym.bareaxy(nb) for nb in nbs] nb = nbs[nbas.index(max(nbas))] nb = pym.aggregate(nb, 1) if pym.bvalidxy(nb) > 0: return nb else: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b, ax, col='r', lw=2) ax = dtl.plot_polygon_xy(stamp, ax, col='b', lw=2) plt.show() raise ValueError
def pl(b1,b2,br): ax = dtl.plot_axes_xy() ax = dtl.plot_polygon_xy(b1,ax,col = 'b',lw = 5.0) ax = dtl.plot_polygon_xy(b2,ax,col = 'g',lw = 5.0) for be in br: ax = dtl.plot_edges_xy(be,ax,mk = 's',col = 'r',lw = 2.0) #ax = dtl.plot_polygon_xy(br,ax,mk = 's',col = 'r',lw = 2.0) plt.show()
def pl(bs): ax = dtl.plot_axes_xy(10) ax = dtl.plot_polygon_xy(b, ax, col='g', lw=2) ax = dtl.plot_edges_xy((s1, s2), ax, col='r', lw=1) for bpy in bs: bpy = pym.contract(bpy, 0.1) ax = dtl.plot_polygon_xy(bpy, ax, col='b', lw=4) plt.show()
def pl(b1, b2, br): ax = dtl.plot_axes_xy() ax = dtl.plot_polygon_xy(b1, ax, col='b', lw=5.0) ax = dtl.plot_polygon_xy(b2, ax, col='g', lw=5.0) for be in br: ax = dtl.plot_edges_xy(be, ax, mk='s', col='r', lw=2.0) #ax = dtl.plot_polygon_xy(br,ax,mk = 's',col = 'r',lw = 2.0) plt.show()
def pl(bs): ax = dtl.plot_axes_xy(10) ax = dtl.plot_polygon_xy(b,ax,col = 'g',lw = 2) ax = dtl.plot_edges_xy((s1,s2),ax,col = 'r',lw = 1) for bpy in bs: bpy = pym.contract(bpy,0.1) ax = dtl.plot_polygon_xy(bpy,ax,col = 'b',lw = 4) plt.show()
def mountains(topo, tip, e=2): '''topographical loop corresponding to the base of a mountain range''' p, d, i, axiom, rules = ((vec3(0, 0, 0), vec3(0, 1, 0), 6, 'X', dict([('X', '{[[X}{]X}F]X'), ('F', 'FA'), ('A', 'F')]))) params = dict(dazimuthal=gtl.rad(25.7), drho=20) pg = pgr.planargraph() for piece in lsy.lgen(p, d, axiom, rules, i, **params): if isinstance(piece, tuple): p1, p2 = piece v1, v2 = pg.fp(p1, 10), pg.fp(p2, 10) e12 = pg.fe(v1, v2) elif isinstance(piece, vec3): pass py = pym.pgtopy(pg, 5)[0] py = pym.smoothxy(py, 0.5, 2, 0) py = pym.pinchb(py, 5)[0] pyprjx = vec3(1, 0, 0).prjps(py) pyprjy = vec3(0, 1, 0).prjps(py) tipprjx = vec3(1, 0, 0).prjps(tip.loop) tipprjy = vec3(0, 1, 0).prjps(tip.loop) recenter = vec3( ((pyprjx[1] + pyprjx[0]) - (tipprjx[1] + tipprjx[0])) / -2.0, ((pyprjy[1] + pyprjy[0]) - (tipprjy[1] + tipprjy[0])) / -2.0, 0) for p in py: p.trn(recenter) pyprjx = vec3(1, 0, 0).prjps(py) pyprjy = vec3(0, 1, 0).prjps(py) tipprjx = vec3(1, 0, 0).prjps(tip.loop) tipprjy = vec3(0, 1, 0).prjps(tip.loop) scale = 1.*(tipprjx[1]-tipprjx[0]+tipprjy[1]-tipprjy[0])/\ ( pyprjx[1]- pyprjx[0]+ pyprjy[1]- pyprjy[0]) for p in py: p.scl(vec3(scale, scale, 0)) #com = vec3(0,0,0).com(tip.loop).tov(vec3(0,0,0).com(py)).uscl(-1) py = pym.ebixy(tip.loop, py)[0] #py = pym.smoothxy(py,0.5,2) py = pym.pinchb(py, 5)[0] newtips = [topo.avert(tip, loop=py)] print('mountains') ax = dtl.plot_axes_xy(400) ax = dtl.plot_polygon_xy(tip.loop, ax, lw=3, col='b') ax = dtl.plot_polygon_xy(py, ax, lw=3, col='g') plt.show() return newtips
def layfootprints(r, t, e): eseam, seams, loops = pym.pgtopy(r, 5, e, findeseam=True) ebnd = seams[eseam] eloop = loops[eseam] k = 0 easement = None for j in range(len(ebnd)): road = r.es[r.elook[(eloop[k - 1], eloop[k])]] edge = (ebnd[j - 1], ebnd[j]) tang = edge[0].tov(edge[1]) norm = tang.crs(vec3(0, 0, 1)).nrm() p1 = edge[0].cp().trn(tang.cp().uscl(0.0)) p2 = edge[0].cp().trn(tang.cp().uscl(1.0)) p3 = p2.cp().trn(norm.uscl(10)) p4 = p1.cp().trn(norm) newfp = [p1, p2, p3, p4] newfp = pym.contract(newfp, 2) newfp = pym.ebdxy(newfp, ebnd)[0] newfp = (newfp, []) preasement = easement if easement is None: easement = newfp else: easement = pym.epuxy(easement, newfp)[0] if not eloop[k] == eloop[k - 2]: k += 1 if False and j > 85: print('walk', j, len(eloop), len(ebnd)) ax = dtl.plot_axes_xy(300) ax = dtl.plot_polygon_xy(ebnd, ax, lw=3, col='b') ax = dtl.plot_points_xy(ebnd, ax, number=True) ax = dtl.plot_edges_xy(edge, ax, lw=7, col='r') ax = dtl.plot_polygon_full_xy(easement, ax, lw=5, col='g') if preasement: ax = dtl.plot_polygon_full_xy(preasement, ax, lw=3, col='m') plt.show() #easement = pym.bsuxy(easement,e) fps = ([easement], [[] for l in range(len(loops) - 1)]) # generate a set of footprints connected to road # footprint must not overlap interiors with ebnd ax = dtl.plot_axes_xy(300) ax = dtl.plot_polygon_xy(ebnd, ax, lw=3, col='b') for fp in fps[0]: ax = dtl.plot_polygon_full_xy(fp, ax, lw=3, col='g') plt.show() return fps
def pl(): ax = rg.plotxy(l = 500) for lp in loops: lpps = [rg.vs[j][1]['p'] for j in lp] lpps = pym.contract(lpps,0.1) ax = dtl.plot_polygon_xy(lpps,ax,lw = 3,col = 'b') plt.show()
def pl(): ax = rg.plotxy(l=500) for lp in loops: lpps = [rg.vs[j][1]['p'] for j in lp] lpps = pym.contract(lpps, 0.1) ax = dtl.plot_polygon_xy(lpps, ax, lw=3, col='b') plt.show()
def aaatest(self): #i = 5 i = 6 p, d = vec3(0, 0, 0), vec3(0, 1, 0) axiom = 'X' rules = dict([('X', '{[[X}{]X}F]X'), ('F', 'FA'), ('A', 'F')]) #rules = dict([('X','F{[X}{]X}FX'),('F','FF')]) #axiom = 'F' #rules = dict([('F','F{[F}F{]F}F')]) params = dict(dazimuthal=gtl.rad(25.7), drho=20) pg = dpg.planargraph() for piece in lsy.lgen(p, d, axiom, rules, i, **params): if isinstance(piece, tuple): p1, p2 = piece v1, v2 = pg.fp(p1, 10), pg.fp(p2, 10) e12 = pg.fe(v1, v2) elif isinstance(piece, vec3): pass py = pym.pgtopy(pg, 1)[0] py = pym.bisectb(py) py = pym.smoothxy(py, 0.5, 2) #py = pym.aggregate(py,2) #ax = pg.plotxy(l = 20) ax = dtl.plot_axes_xy(20) ax = dtl.plot_polygon_xy(py, ax, lw=3) plt.show()
def aaatest(self): #i = 5 i = 6 p,d = vec3(0,0,0),vec3(0,1,0) axiom = 'X' rules = dict([('X','{[[X}{]X}F]X'),('F','FA'),('A','F')]) #rules = dict([('X','F{[X}{]X}FX'),('F','FF')]) #axiom = 'F' #rules = dict([('F','F{[F}F{]F}F')]) params = dict(dazimuthal = gtl.rad(25.7),drho = 20) pg = dpg.planargraph() for piece in lsy.lgen(p,d,axiom,rules,i,**params): if isinstance(piece,tuple): p1,p2 = piece v1,v2 = pg.fp(p1,10),pg.fp(p2,10) e12 = pg.fe(v1,v2) elif isinstance(piece,vec3):pass py = pym.pgtopy(pg,1)[0] py = pym.bisectb(py) py = pym.smoothxy(py,0.5,2) #py = pym.aggregate(py,2) #ax = pg.plotxy(l = 20) ax = dtl.plot_axes_xy(20) ax = dtl.plot_polygon_xy(py,ax,lw = 3) plt.show()
def mountains(topo,tip,e = 2): '''topographical loop corresponding to the base of a mountain range''' p,d,i,axiom,rules = ((vec3(0,0,0),vec3(0,1,0),6, 'X',dict([('X','{[[X}{]X}F]X'),('F','FA'),('A','F')]))) params = dict(dazimuthal = gtl.rad(25.7),drho = 20) pg = pgr.planargraph() for piece in lsy.lgen(p,d,axiom,rules,i,**params): if isinstance(piece,tuple): p1,p2 = piece v1,v2 = pg.fp(p1,10),pg.fp(p2,10) e12 = pg.fe(v1,v2) elif isinstance(piece,vec3):pass py = pym.pgtopy(pg,5)[0] py = pym.smoothxy(py,0.5,2,0) py = pym.pinchb(py,5)[0] pyprjx = vec3(1,0,0).prjps(py) pyprjy = vec3(0,1,0).prjps(py) tipprjx = vec3(1,0,0).prjps(tip.loop) tipprjy = vec3(0,1,0).prjps(tip.loop) recenter = vec3( ((pyprjx[1]+pyprjx[0])-(tipprjx[1]+tipprjx[0]))/-2.0, ((pyprjy[1]+pyprjy[0])-(tipprjy[1]+tipprjy[0]))/-2.0,0) for p in py:p.trn(recenter) pyprjx = vec3(1,0,0).prjps(py) pyprjy = vec3(0,1,0).prjps(py) tipprjx = vec3(1,0,0).prjps(tip.loop) tipprjy = vec3(0,1,0).prjps(tip.loop) scale = 1.*(tipprjx[1]-tipprjx[0]+tipprjy[1]-tipprjy[0])/\ ( pyprjx[1]- pyprjx[0]+ pyprjy[1]- pyprjy[0]) for p in py:p.scl(vec3(scale,scale,0)) #com = vec3(0,0,0).com(tip.loop).tov(vec3(0,0,0).com(py)).uscl(-1) py = pym.ebixy(tip.loop,py)[0] #py = pym.smoothxy(py,0.5,2) py = pym.pinchb(py,5)[0] newtips = [topo.avert(tip,loop = py)] print('mountains') ax = dtl.plot_axes_xy(400) ax = dtl.plot_polygon_xy(tip.loop,ax,lw = 3,col = 'b') ax = dtl.plot_polygon_xy(py,ax,lw = 3,col = 'g') plt.show() return newtips
def atest_pgbleed(self): def trimtofp(p1,p2,r = 5): ips = pym.sintbxyp(p1,p2,fp) if len(ips) > 0: for ip in ips: if ip.isnear(p1):continue p2 = p1.lerp(ip,1-r/p1.d(ip)) return p2 rg = pgr.planargraph() easement = 10 fp = vec3(0,0,0).pring(100,8) exp = fp[-1].lerp(fp[0],0.5) exn = vec3(0,0,1).crs(fp[-1].tov(fp[0])).nrm() ex1 = exp.cp() ex2 = ex1.cp().trn(exn.cp().uscl(easement)) i1 = rg.av(p = ex1,l = 0) i2,r1 = rg.mev(i1,{'p':ex2,'l':0},{}) tip = i2 tv = rg.vs[tip] avs = [rg.vs[k] for k in rg.orings[tip]] if len(avs) == 1: op = tv[1]['p'] nptn = avs[0][1]['p'].tov(op).nrm().uscl(100) np = op.cp().trn(nptn) np = trimtofp(op,np,easement+10) nv,nr = rg.mev(tip,{'p':np,'l':0},{}) start = nv tip = start fp_relax = pym.aggregate(pym.contract(fp,20),20) for p_relax in fp_relax: nv,nr = rg.mev(tip,{'p':p_relax,'l':0},{}) tip = nv ne = rg.ae(tip,start,**{}) rpy = pym.pgbleed(rg,5) ax = dtl.plot_axes_xy(300) ax = rg.plotxy(ax) ax = dtl.plot_polygon_xy(fp,ax,lw = 2,col = 'b') ax = dtl.plot_polygon_xy(fp_relax,ax,lw = 2,col = 'b') ax = dtl.plot_polygon_full_xy(rpy,ax,lw = 2,col = 'g') plt.show()
def atest_pgbleed(self): def trimtofp(p1, p2, r=5): ips = pym.sintbxyp(p1, p2, fp) if len(ips) > 0: for ip in ips: if ip.isnear(p1): continue p2 = p1.lerp(ip, 1 - r / p1.d(ip)) return p2 rg = pgr.planargraph() easement = 10 fp = vec3(0, 0, 0).pring(100, 8) exp = fp[-1].lerp(fp[0], 0.5) exn = vec3(0, 0, 1).crs(fp[-1].tov(fp[0])).nrm() ex1 = exp.cp() ex2 = ex1.cp().trn(exn.cp().uscl(easement)) i1 = rg.av(p=ex1, l=0) i2, r1 = rg.mev(i1, {'p': ex2, 'l': 0}, {}) tip = i2 tv = rg.vs[tip] avs = [rg.vs[k] for k in rg.orings[tip]] if len(avs) == 1: op = tv[1]['p'] nptn = avs[0][1]['p'].tov(op).nrm().uscl(100) np = op.cp().trn(nptn) np = trimtofp(op, np, easement + 10) nv, nr = rg.mev(tip, {'p': np, 'l': 0}, {}) start = nv tip = start fp_relax = pym.aggregate(pym.contract(fp, 20), 20) for p_relax in fp_relax: nv, nr = rg.mev(tip, {'p': p_relax, 'l': 0}, {}) tip = nv ne = rg.ae(tip, start, **{}) rpy = pym.pgbleed(rg, 5) ax = dtl.plot_axes_xy(300) ax = rg.plotxy(ax) ax = dtl.plot_polygon_xy(fp, ax, lw=2, col='b') ax = dtl.plot_polygon_xy(fp_relax, ax, lw=2, col='b') ax = dtl.plot_polygon_full_xy(rpy, ax, lw=2, col='g') plt.show()
def test_ccwboxes(self): container = db.persistent_container('dump','boxes') if container.load():boxes = container.data blgfps = pym.ebuxy_special(boxes) ax = dtl.plot_axes_xy(200) for b in boxes:ax = dtl.plot_polygon_xy(b,ax,lw = 2,col = 'g') plt.show()
def atest_ebuxy(self): def pl(b1, b2, br): ax = dtl.plot_axes_xy(20) ax = dtl.plot_polygon_xy(b1, ax, col='b', lw=5.0) ax = dtl.plot_polygon_xy(b2, ax, col='g', lw=5.0) for b in br: ax = dtl.plot_polygon_xy(b, ax, col='r', lw=2.0) plt.show() vb = vec3(0, 0, 0).sq(400, 400) dx, dy, xn, yn = 20, 20, 4, 3 o = vec3(-dx * xn / 2.0, -dy * yn, 0).com(vb) vgrid = [ o.cp().trn(vec3(x * dx, y * dy, 0)) for y in range(yn) for x in range(xn) ] boxes = [p.sq(dx, dy) for p in vgrid] boxes = [b for b in boxes if pym.binbxy(b, vb)] box = pym.bsuxy(boxes) ax = dtl.plot_axes_xy(300) ax = dtl.plot_polygon_xy(vb, ax, lw=2, col='b') for b in boxes: ax = dtl.plot_polygon_xy(b, ax, lw=2, col='g') for b in box: ax = dtl.plot_polygon_xy(b, ax, lw=2, col='r') plt.show() b1 = vec3(7, 0, 0).sq(8, 8) b2 = vec3(0, 0, 0).sq(8, 8) br = pym.ebuxy(b1, b2) pl(b1, b2, br) self.assertTrue(len(br) == 1) self.assertTrue(len(br[0]) == 8) b1 = vec3(0, 0, 0).sq(20, 8) b2 = vec3(0, 8, 0).sq(20, 8) br = pym.ebuxy(b1, b2) pl(b1, b2, br) self.assertTrue(len(br) == 1) self.assertTrue(len(br[0]) == 6) b1 = vec3(8, 2, 0).sq(8, 8) b2 = vec3(0, 0, 0).sq(8, 8) br = pym.ebuxy(b1, b2) pl(b1, b2, br) self.assertTrue(len(br) == 1) self.assertTrue(len(br[0]) == 10)
def test_ccwboxes(self): container = db.persistent_container('dump', 'boxes') if container.load(): boxes = container.data blgfps = pym.ebuxy_special(boxes) ax = dtl.plot_axes_xy(200) for b in boxes: ax = dtl.plot_polygon_xy(b, ax, lw=2, col='g') plt.show()
def test_av(self): fp = dbl.block('H',10,25,25) rg = ptg.partitiongraph() bs = pym.bsegsxy(fp[0],vec3(0,-100,0),vec3(0,100,0)) for b in bs: i = rg.av(b = [b,[]],p = vec3(0,0,0).com(b),l = 0) rg.plotxy() plt.show() pg = rg.bgraph() pgpy = pg.polygon(1,'ccw') ax = pg.plotxy() #ax = dtl.plot_axes_xy(20) #ax = dtl.plot_polygon_full_xy(pgpy,ax,lw = 2) ax = dtl.plot_polygon_xy(pgpy[0],ax,lw = 2) for pgp in pgpy[1]: ax = dtl.plot_polygon_xy(pgp,ax,lw = 2) plt.show()
def test_av(self): fp = dbl.block('H', 10, 25, 25) rg = ptg.partitiongraph() bs = pym.bsegsxy(fp[0], vec3(0, -100, 0), vec3(0, 100, 0)) for b in bs: i = rg.av(b=[b, []], p=vec3(0, 0, 0).com(b), l=0) rg.plotxy() plt.show() pg = rg.bgraph() pgpy = pg.polygon(1, 'ccw') ax = pg.plotxy() #ax = dtl.plot_axes_xy(20) #ax = dtl.plot_polygon_full_xy(pgpy,ax,lw = 2) ax = dtl.plot_polygon_xy(pgpy[0], ax, lw=2) for pgp in pgpy[1]: ax = dtl.plot_polygon_xy(pgp, ax, lw=2) plt.show()
def ebuxy(b1, b2, epsilon=0.1, debug=False, holes=False): b1segs, b2segs = bsegbxy(b1, b2), bsegbxy(b2, b1) bo = lambda s1, s2, b: s1.mid(s2).inbxy(b) def inn(p): pn = vec3(0, 0, 1).crs(p[0].tov(p[1])).nrm().uscl(2 * epsilon) pm = p[0].mid(p[1]) ep = pm.cp().trn(pn) if not ep.inbxy(b1) and not ep.inbxy(b2): return False ep = pm.cp().trn(pn.flp()) if not ep.inbxy(b1) and not ep.inbxy(b2): return False return True b1inb2 = [p for p in b1segs if bo(p[0], p[1], b2)] b2inb1 = [p for p in b2segs if bo(p[0], p[1], b1)] b1only = [p for p in b1segs if not p in b1inb2 and not inn(p)] b2only = [p for p in b2segs if not p in b2inb1 and not inn(p)] dfs = sloops(b1only + b2only, epsilon) if debug: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b2, ax, lw=2, col='m') for edge in b1segs: ax = dtl.plot_edges_xy(edge, ax, lw=5, col='b') for edge in b1only: ax = dtl.plot_edges_xy(edge, ax, lw=8, col='b') for edge in b1inb2: ax = dtl.plot_edges_xy(edge, ax, lw=3, col='g') #for edge in b2only: # ax = dtl.plot_edges_xy(edge,ax,lw = 5,col = 'g') plt.show() if len(dfs) > 1: edfs = 0 for jdfs, lp in enumerate(dfs): if binbxy(dfs[edfs], lp, ie=0): edfs = jdfs if holes: print('genus of ebuxy changed!') return [(dfs.pop(edfs), dfs)] else: print('discarding holes resulting from ebuxy!') return [dfs[edfs]] ''' print('promisedland?') ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(dfs[edfs],ax,lw = 7,col = 'r') ax = dtl.plot_polygon_xy(dfs[0],ax,lw = 5,col = 'b') ax = dtl.plot_polygon_xy(dfs[1],ax,lw = 3,col = 'g') #ax = dtl.plot_polygon_xy(b1,ax,ls = '-.',lw = 5,col = 'k') #ax = dtl.plot_polygon_xy(b2,ax,ls = '--',lw = 5,col = 'k') plt.show() ''' if holes: return [(dfs[0], [])] else: return dfs
def test_intrixy(self): a = vec3(-93.6169662475586, 46.23309326171875, 0.0) b = vec3(28.083663940429688, 48.28422546386719, 0.0) c = vec3(25.696874618530273, 48.28422546386719, 0.0) p = vec3(-93.34214782714844, 43.73178482055664, 0.0) i = p.intrixy(a, b, c) self.assertFalse(i) ax = dtl.plot_axes_xy(100) ax = dtl.plot_points_xy((a, b, c, p), ax) ax = dtl.plot_polygon_xy((a, b, c), ax, lw=2, col='g') plt.show()
def test_intrixy(self): a = vec3(-93.6169662475586, 46.23309326171875, 0.0) b = vec3(28.083663940429688, 48.28422546386719, 0.0) c = vec3(25.696874618530273, 48.28422546386719, 0.0) p = vec3(-93.34214782714844, 43.73178482055664, 0.0) i = p.intrixy(a,b,c) self.assertFalse(i) ax = dtl.plot_axes_xy(100) ax = dtl.plot_points_xy((a,b,c,p),ax) ax = dtl.plot_polygon_xy((a,b,c),ax,lw = 2,col = 'g') plt.show()
def ebuxy(b1,b2,epsilon = 0.1,debug = False,holes = False): b1segs,b2segs = bsegbxy(b1,b2),bsegbxy(b2,b1) bo = lambda s1,s2,b : s1.mid(s2).inbxy(b) def inn(p): pn = vec3(0,0,1).crs(p[0].tov(p[1])).nrm().uscl(2*epsilon) pm = p[0].mid(p[1]) ep = pm.cp().trn(pn) if not ep.inbxy(b1) and not ep.inbxy(b2):return False ep = pm.cp().trn(pn.flp()) if not ep.inbxy(b1) and not ep.inbxy(b2):return False return True b1inb2 = [p for p in b1segs if bo(p[0],p[1],b2)] b2inb1 = [p for p in b2segs if bo(p[0],p[1],b1)] b1only = [p for p in b1segs if not p in b1inb2 and not inn(p)] b2only = [p for p in b2segs if not p in b2inb1 and not inn(p)] dfs = sloops(b1only+b2only,epsilon) if debug: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b2,ax,lw = 2,col = 'm') for edge in b1segs: ax = dtl.plot_edges_xy(edge,ax,lw = 5,col = 'b') for edge in b1only: ax = dtl.plot_edges_xy(edge,ax,lw = 8,col = 'b') for edge in b1inb2: ax = dtl.plot_edges_xy(edge,ax,lw = 3,col = 'g') #for edge in b2only: # ax = dtl.plot_edges_xy(edge,ax,lw = 5,col = 'g') plt.show() if len(dfs) > 1: edfs = 0 for jdfs,lp in enumerate(dfs): if binbxy(dfs[edfs],lp,ie = 0): edfs = jdfs if holes: print('genus of ebuxy changed!') return [(dfs.pop(edfs),dfs)] else: print('discarding holes resulting from ebuxy!') return [dfs[edfs]] ''' print('promisedland?') ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(dfs[edfs],ax,lw = 7,col = 'r') ax = dtl.plot_polygon_xy(dfs[0],ax,lw = 5,col = 'b') ax = dtl.plot_polygon_xy(dfs[1],ax,lw = 3,col = 'g') #ax = dtl.plot_polygon_xy(b1,ax,ls = '-.',lw = 5,col = 'k') #ax = dtl.plot_polygon_xy(b2,ax,ls = '--',lw = 5,col = 'k') plt.show() ''' if holes:return [(dfs[0],[])] else:return dfs
def ___lsystemboundary(b): p, d, i, axiom, rules = ((vec3(0, 0, 0), vec3(0, 1, 0), 5, 'X', dict([('X', '{[[X}{]X}F]X'), ('F', 'FA'), ('A', 'F')]))) params = dict(dazimuthal=gtl.rad(25.7), drho=20) pg = dpg.planargraph() for piece in lsy.lgen(p, d, axiom, rules, i, **params): if isinstance(piece, tuple): p1, p2 = piece v1, v2 = pg.fp(p1, 10), pg.fp(p2, 10) e12 = pg.fe(v1, v2) elif isinstance(piece, vec3): pass py = pym.pgtopy(pg, 5)[0] py = pym.smoothxy(py, 0.5, 2) #py = pym.aggregate(py,2) py = pym.pinchb(py, 5) #ax = dtl.plot_axes_xy(400) #ax = pg.plotxy(ax,l = 300) #ax = dtl.plot_polygon_xy(b,ax,lw = 3,col = 'b') #ax = dtl.plot_polygon_xy(py,ax,lw = 3,col = 'g') #plt.show() pyscale = vec3(0, 1, 0).prjps(py) tipscale = vec3(0, 1, 0).prjps(b) pyscale = pyscale[1] - pyscale[0] tipscale = tipscale[1] - tipscale[0] scale = tipscale / pyscale com = vec3(0, 0, 0).com(b).tov(vec3(0, 0, 0).com(py)).uscl(-1) for p in py: p.scl(vec3(scale, scale, 0)).trn(com) ax = dtl.plot_axes_xy(400) ax = dtl.plot_polygon_xy(b, ax, lw=3, col='b') ax = dtl.plot_polygon_xy(py, ax, lw=3, col='g') plt.show() return py
def atest_ebuxy(self): def pl(b1,b2,br): ax = dtl.plot_axes_xy(20) ax = dtl.plot_polygon_xy(b1,ax,col = 'b',lw = 5.0) ax = dtl.plot_polygon_xy(b2,ax,col = 'g',lw = 5.0) for b in br:ax = dtl.plot_polygon_xy(b,ax,col = 'r',lw = 2.0) plt.show() vb = vec3(0,0,0).sq(400,400) dx,dy,xn,yn = 20,20,4,3 o = vec3(-dx*xn/2.0,-dy*yn,0).com(vb) vgrid = [o.cp().trn(vec3(x*dx,y*dy,0)) for y in range(yn) for x in range(xn)] boxes = [p.sq(dx,dy) for p in vgrid] boxes = [b for b in boxes if pym.binbxy(b,vb)] box = pym.bsuxy(boxes) ax = dtl.plot_axes_xy(300) ax = dtl.plot_polygon_xy(vb,ax,lw = 2,col = 'b') for b in boxes:ax = dtl.plot_polygon_xy(b,ax,lw = 2,col = 'g') for b in box:ax = dtl.plot_polygon_xy(b,ax,lw = 2,col = 'r') plt.show() b1 = vec3(7,0,0).sq(8,8) b2 = vec3(0,0,0).sq(8,8) br = pym.ebuxy(b1,b2) pl(b1,b2,br) self.assertTrue(len(br) == 1) self.assertTrue(len(br[0]) == 8) b1 = vec3(0,0,0).sq(20,8) b2 = vec3(0,8,0).sq(20,8) br = pym.ebuxy(b1,b2) pl(b1,b2,br) self.assertTrue(len(br) == 1) self.assertTrue(len(br[0]) == 6) b1 = vec3(8,2,0).sq(8,8) b2 = vec3(0,0,0).sq(8,8) br = pym.ebuxy(b1,b2) pl(b1,b2,br) self.assertTrue(len(br) == 1) self.assertTrue(len(br[0]) == 10)
def plotxy(self,ax = None,scale = 250): if ax is None:ax = dtl.plot_axes_xy(scale) ax = pgr.planargraph.plotxy(self,ax) ekeys = [] for vx in range(self.vcnt): v = self.vs[vx] if v is None:continue vb = v[1]['b'] vrtls = '-' if 't' in v[1]:vrtls = '--' if 'developed' in v[1]['t'] else '-' conr = 1 if pym.bccw(vb[0]) else -1 ax = dtl.plot_polygon_xy(pym.contract(vb[0],conr), ax,lw = 2,ls = vrtls,col = 'b') for ib in vb[1]: conr = 1 if pym.bccw(ib) else -1 ax = dtl.plot_polygon_xy(pym.contract(ib,conr),ax,lw = 2,col = 'r') vbc = vec3(0,0,0).com(vb[0]) rs = str(vx)+','+str(self.orings[vx])#+',\n'+str(v[1]['type']) ax = dtl.plot_point_xy_annotate(vbc,ax,rs) for ve in self.orings[vx]: ov = self.vs[ve] if ov is None:continue if not (vx,ve) in ekeys and not (ve,vx) in ekeys: ekeys.append((vx,ve)) aws = pym.badjbxy(vb[0],ov[1]['b'][0],0) for awx in range(len(aws)): vwx,owx = aws[awx] ex,ekws = self.es[self.elook[ekeys[-1]]] door = vb[0][vwx-1].lerp(vb[0][vwx],ekws['p']) ax = dtl.plot_point_xy(door,ax,col = 'r') ovbc = vec3(0,0,0).com(self.vs[ve][1]['b'][0]) ax = dtl.plot_edges_xy((vbc,ovbc),ax,lw = 3,col = 'c') #for ep in v[1]['exits']: # ax = dtl.plot_point_xy(ep,ax,mk = 's',col = 'r') return ax
def splotch(g, subseq): irx, easement, splotchseq = subseq.split(',') irx, easement = int(irx), float(easement) print('SPLOTCH!', subseq, splotchseq) iv = g.vs[irx] fp = iv[1]['fp'] xprj = vec3(1, 0, 0).prjps(fp) yprj = vec3(0, 1, 0).prjps(fp) xlen = xprj[1] - xprj[0] ylen = yprj[1] - yprj[0] rad = max(xlen, ylen) / 2.0 #r1 = vec3(0,10,0).com(fp).sq(30,40) #r2 = vec3(-10,-20,0).com(fp).sq(20,40) #r3 = vec3(0,-10,0).com(fp).sq(50,30) #rs = [r1,r2,r3] #r = rs.pop(0) #while rs:r = pym.ebuxy(r,rs.pop(0)) r = dbl.block('H', rad / 3.0, rad, rad) r = r[0] for j in range(3): r = pym.smoothxy(r, 0.1) #r = pym.ebixy(fp,r) l = fp nv = g.sv(irx, l, r) ax = dtl.plot_axes_xy(2 * rad) ax = dtl.plot_polygon_xy(fp, ax, lw=6, col=None) ax = dtl.plot_polygon_xy(r, ax, lw=4, col='b') ax = dtl.plot_polygon_xy(l, ax, lw=2, col='g') plt.show() return g
def splotch(g,subseq): irx,easement,splotchseq = subseq.split(',') irx,easement = int(irx),float(easement) print('SPLOTCH!',subseq,splotchseq) iv = g.vs[irx] fp = iv[1]['fp'] xprj = vec3(1,0,0).prjps(fp) yprj = vec3(0,1,0).prjps(fp) xlen = xprj[1]-xprj[0] ylen = yprj[1]-yprj[0] rad = max(xlen,ylen)/2.0 #r1 = vec3(0,10,0).com(fp).sq(30,40) #r2 = vec3(-10,-20,0).com(fp).sq(20,40) #r3 = vec3(0,-10,0).com(fp).sq(50,30) #rs = [r1,r2,r3] #r = rs.pop(0) #while rs:r = pym.ebuxy(r,rs.pop(0)) r = dbl.block('H',rad/3.0,rad,rad) r = r[0] for j in range(3):r = pym.smoothxy(r,0.1) #r = pym.ebixy(fp,r) l = fp nv = g.sv(irx,l,r) ax = dtl.plot_axes_xy(2*rad) ax = dtl.plot_polygon_xy(fp,ax,lw = 6,col = None) ax = dtl.plot_polygon_xy(r,ax,lw = 4,col = 'b') ax = dtl.plot_polygon_xy(l,ax,lw = 2,col = 'g') plt.show() return g
def atest_bgraph(self): fp = dbl.block('H',10,25,25) v1 = {'b':fp,'p':vec3(0,0,0).com(fp[0]),'l':0} rg = ptg.partitiongraph() ip = vec3(0.5,0.5,0) i1 = rg.av(**v1) #i2 = rg.bv(0,ip,vec3(1,0,0)) i3 = rg.bv(0,ip,vec3(0,1,0)) #i4 = rg.bv(1,ip,vec3(0,1,0)) rg.vves() pg = rg.bgraph() #pdb.set_trace() pgpy = pg.polygon(1,'ccw') ax = pg.plotxy() #ax = dtl.plot_axes_xy(20) #ax = dtl.plot_polygon_full_xy(pgpy,ax,lw = 2) ax = dtl.plot_polygon_xy(pgpy[0],ax,lw = 2) for pgp in pgpy[1]: ax = dtl.plot_polygon_xy(pgp,ax,lw = 2) plt.show()
def atest_bgraph(self): fp = dbl.block('H', 10, 25, 25) v1 = {'b': fp, 'p': vec3(0, 0, 0).com(fp[0]), 'l': 0} rg = ptg.partitiongraph() ip = vec3(0.5, 0.5, 0) i1 = rg.av(**v1) #i2 = rg.bv(0,ip,vec3(1,0,0)) i3 = rg.bv(0, ip, vec3(0, 1, 0)) #i4 = rg.bv(1,ip,vec3(0,1,0)) rg.vves() pg = rg.bgraph() #pdb.set_trace() pgpy = pg.polygon(1, 'ccw') ax = pg.plotxy() #ax = dtl.plot_axes_xy(20) #ax = dtl.plot_polygon_full_xy(pgpy,ax,lw = 2) ax = dtl.plot_polygon_xy(pgpy[0], ax, lw=2) for pgp in pgpy[1]: ax = dtl.plot_polygon_xy(pgp, ax, lw=2) plt.show()
def plotxy(self,ax = None): scale = vec3(1,0,0).prjps(self.footprint) scale = scale[1]-scale[0] if ax is None:ax = dtl.plot_axes_xy(scale) for vx in range(self.vcnt): v = self.vs[vx] if v is None:continue vb = v[1]['fp'] vrtls = '-' if 'developed' in v[1]['type'] else '--' #vrtls = '--' if 'natural' in v[1]['type'] else '-' ax = dtl.plot_polygon_xy( pym.contract(vb,0.01*scale),ax,lw = 2,ls = vrtls,col = None) vbc = vec3(0,0,0).com(vb) rs = str(vx)+','+str(v[1]['edges'])+',\n'+str(v[1]['type']) ax = dtl.plot_point_xy_annotate(vbc,ax,rs) for ve in v[1]['edges']: if self.vs[ve] is None:continue ovbc = vec3(0,0,0).com(self.vs[ve][1]['fp']) ax = dtl.plot_edges_xy((vbc,ovbc),ax,lw = 3,col = 'c') for ep in v[1]['exits']: ax = dtl.plot_point_xy(ep,ax,mk = 's',col = 'r') ax = dtl.plot_polygon_xy(self.footprint,ax,lw = 1,col = 'g') return ax
def ___lsystemboundary(b): p,d,i,axiom,rules = ((vec3(0,0,0),vec3(0,1,0),5, 'X',dict([('X','{[[X}{]X}F]X'),('F','FA'),('A','F')]))) params = dict(dazimuthal = gtl.rad(25.7),drho = 20) pg = dpg.planargraph() for piece in lsy.lgen(p,d,axiom,rules,i,**params): if isinstance(piece,tuple): p1,p2 = piece v1,v2 = pg.fp(p1,10),pg.fp(p2,10) e12 = pg.fe(v1,v2) elif isinstance(piece,vec3):pass py = pym.pgtopy(pg,5)[0] py = pym.smoothxy(py,0.5,2) #py = pym.aggregate(py,2) py = pym.pinchb(py,5) #ax = dtl.plot_axes_xy(400) #ax = pg.plotxy(ax,l = 300) #ax = dtl.plot_polygon_xy(b,ax,lw = 3,col = 'b') #ax = dtl.plot_polygon_xy(py,ax,lw = 3,col = 'g') #plt.show() pyscale = vec3(0,1,0).prjps(py) tipscale = vec3(0,1,0).prjps(b) pyscale = pyscale[1]-pyscale[0] tipscale = tipscale[1]-tipscale[0] scale = tipscale/pyscale com = vec3(0,0,0).com(b).tov(vec3(0,0,0).com(py)).uscl(-1) for p in py:p.scl(vec3(scale,scale,0)).trn(com) ax = dtl.plot_axes_xy(400) ax = dtl.plot_polygon_xy(b,ax,lw = 3,col = 'b') ax = dtl.plot_polygon_xy(py,ax,lw = 3,col = 'g') plt.show() return py
def pg(self,*ags,**kws): pg = dpg.planargraph() for piece in lsy.lgen(*ags,**kws): if isinstance(piece,tuple): p1,p2 = piece v1,v2 = pg.fp(p1,10),pg.fp(p2,10) e12 = pg.fe(v1,v2) elif isinstance(piece,vec3):pass py = pym.pgtopy(pg,1)[0] py = pym.bisectb(py) py = pym.smoothxy(py,0.5,2) #ax = pg.plotxy(l = 20) ax = dtl.plot_axes_xy(50) ax = dtl.plot_polygon_xy(py,ax,lw = 3) plt.show()
def pg(self, *ags, **kws): pg = dpg.planargraph() for piece in lsy.lgen(*ags, **kws): if isinstance(piece, tuple): p1, p2 = piece v1, v2 = pg.fp(p1, 10), pg.fp(p2, 10) e12 = pg.fe(v1, v2) elif isinstance(piece, vec3): pass py = pym.pgtopy(pg, 1)[0] py = pym.bisectb(py) py = pym.smoothxy(py, 0.5, 2) #ax = pg.plotxy(l = 20) ax = dtl.plot_axes_xy(50) ax = dtl.plot_polygon_xy(py, ax, lw=3) plt.show()
def test_sintbxyp(self): u1, u2 = (vec3(77.000000, 33.001942, 0.000000), vec3(63.000000, 33.000004, 0.000000)) b = [ vec3(75.000000, 35.000011, 0.000000), vec3(76.999992, 35.000011, 0.000000), vec3(76.999992, 32.999996, 0.000000), vec3(67.000000, 33.000000, 0.000000), vec3(66.999992, 22.999996, 0.000000), vec3(33.000000, 23.000004, 0.000000), vec3(33.000000, 33.001392, 0.000000), vec3(23.001953, 33.000004, 0.000000), vec3(23.001545, 61.998047, 0.000000), vec3(23.001442, 63.001602, 0.000000), vec3(18.000002, 63.001541, 0.000000), vec3(16.999865, 63.001438, 0.000000), vec3(17.000000, 62.000000, 0.000000), vec3(17.000000, 58.000000, 0.000000), vec3(17.000000, 42.000000, 0.000000), vec3(17.000000, 38.000000, 0.000000), vec3(17.000000, 18.000000, 0.000000), vec3(5.000000, 18.000000, 0.000000), vec3(5.000000, 20.000000, 0.000000), vec3(5.000000, 38.000000, 0.000000), vec3(5.000000, 40.000000, 0.000000), vec3(5.000000, 42.000000, 0.000000), vec3(5.000000, 58.000000, 0.000000), vec3(5.000000, 60.000000, 0.000000), vec3(5.000000, 62.000000, 0.000000), vec3(5.000000, 63.000206, 0.000000), vec3(5.000000, 75.000000, 0.000000), vec3(16.998253, 75.000000, 0.000000), vec3(17.999998, 75.000000, 0.000000), vec3(19.999998, 75.000000, 0.000000), vec3(22.000002, 75.000000, 0.000000), vec3(23.000202, 75.000000, 0.000000), vec3(34.999996, 75.000000, 0.000000), vec3(34.999996, 63.001747, 0.000000), vec3(34.999996, 61.999722, 0.000000), vec3(34.999996, 60.000000, 0.000000), vec3(34.999996, 58.000000, 0.000000), vec3(35.000000, 36.999996, 0.000000), vec3(35.000000, 35.000004, 0.000000), vec3(36.999866, 35.000000, 0.000000), vec3(63.000004, 35.000004, 0.000000), vec3(64.999992, 35.000004, 0.000000), vec3(64.999992, 37.000004, 0.000000), vec3(64.999992, 43.001785, 0.000000), vec3(64.999992, 45.000004, 0.000000), vec3(62.999996, 45.000004, 0.000000), vec3(56.999790, 45.000004, 0.000000), vec3(44.999996, 45.000000, 0.000000), vec3(44.999996, 56.998211, 0.000000), vec3(44.999996, 58.000000, 0.000000), vec3(44.999996, 60.000000, 0.000000), vec3(44.999996, 62.000000, 0.000000), vec3(45.000000, 63.000206, 0.000000), vec3(45.000000, 75.000000, 0.000000), vec3(57.000000, 75.000000, 0.000000), vec3(57.999996, 75.000000, 0.000000), vec3(59.999992, 75.000000, 0.000000), vec3(62.000004, 75.000000, 0.000000), vec3(63.000195, 75.000000, 0.000000), vec3(74.999985, 75.000000, 0.000000), vec3(74.999985, 63.001747, 0.000000), vec3(74.999985, 60.000004, 0.000000), vec3(74.999985, 57.999996, 0.000000), vec3(63.001968, 58.000004, 0.000000), vec3(63.001446, 63.000515, 0.000000), vec3(58.000008, 63.000000, 0.000000), vec3(56.998913, 63.001442, 0.000000), vec3(56.998459, 58.000004, 0.000000), vec3(56.998562, 56.999187, 0.000000), vec3(67.000008, 57.000004, 0.000000), vec3(67.000000, 47.000000, 0.000000), vec3(74.999992, 47.000004, 0.000000), ] ips = pym.sintbxyp(u1, u2, b, ieb=False) ax = dtl.plot_axes_xy(100) ax = dtl.plot_polygon_xy(b, ax, lw=2, col='g') ax = dtl.plot_points_xy((u1, u2), ax, cs=['b'] * 2) ax = dtl.plot_edges_xy((u1, u2), ax, col='b') ax = dtl.plot_points_xy(ips, ax, cs=['r'] * len(ips)) print('IPS', ips) plt.show() pdb.set_trace()
def test_bnrm(self): def pl(): ax = dtl.plot_axes_xy(700) ax = dtl.plot_polygon_xy(fp, ax, lw=2, col='g') ax = dtl.plot_points_xy(fp, ax, number=True) plt.show() ebnd = db.persistent_container('/home/cogle/dev/dilapidator/test/', 'ebnd') ebnd.load() ebnd = ebnd.data ax = dtl.plot_axes_xy(120) ax = dtl.plot_polygon_xy(ebnd, ax, lw=4, col='r') ax = dtl.plot_points_xy(ebnd, ax, number=True) plt.show() fp = [ vec3(-6.9831085205078125, 121.9827880859375, 0.0), vec3(-26.983108520507812, 121.9827880859375, 0.0), vec3(-46.98310852050781, 121.9827880859375, 0.0), vec3(-66.98310852050781, 121.9827880859375, 0.0), vec3(-85.984375, 121.9827880859375, 0.0), vec3(-85.98310852050781, 102.9827880859375, 0.0), vec3(-85.98310852050781, 82.9827880859375, 0.0), vec3(-85.98310852050781, 63.9814453125, 0.0), vec3(-66.98310852050781, 63.9827880859375, 0.0), vec3(-46.98310852050781, 63.9827880859375, 0.0), vec3(-26.983108520507812, 63.9827880859375, 0.0), vec3(-6.9831085205078125, 63.9827880859375, 0.0), vec3(13.016891479492188, 63.9827880859375, 0.0), vec3(33.01689147949219, 63.9827880859375, 0.0), vec3(53.01689147949219, 63.9827880859375, 0.0), vec3(73.01689147949219, 63.9827880859375, 0.0), vec3(93.01689147949219, 63.9827880859375, 0.0), vec3(112.017578125, 63.9827880859375, 0.0), vec3(112.01689147949219, 82.9827880859375, 0.0), vec3(112.01689147949219, 102.9827880859375, 0.0), vec3(112.01689147949219, 121.9833984375, 0.0), vec3(93.01689147949219, 121.9827880859375, 0.0), vec3(73.01689147949219, 121.9827880859375, 0.0), vec3(53.01689147949219, 121.9827880859375, 0.0), vec3(33.01689147949219, 121.9827880859375, 0.0), vec3(13.016891479492188, 121.9827880859375, 0.0) ] ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(fp, ax, lw=3, col='b') ax = dtl.plot_points_xy(fp, ax, number=True) plt.show() self.assertTrue(pym.bnrm(fp).isnear(vec3(0, 0, 1))) vb = vec3(-100, 100, 0).sq(400, 400) dx, dy, xn, yn = 20, 20, 10, 30 o = vec3(-dx * xn / 2.0, -dy * yn, 0).com(vb) vgrid = [ o.cp().trn(vec3(x * dx, y * dy, 0)) for y in range(yn) for x in range(xn) ] boxes = [p.sq(dx, dy) for p in vgrid] boxes = [b for b in boxes if pym.binbxy(b, vb)] box = pym.bsuxy(boxes) self.assertTrue(pym.bnrm(box[0]).isnear(vec3(0, 0, 1))) fp = [ vec3(0, 0, 0), vec3(20, 0, 0), vec3(20, -20, 0), vec3(40, -30, 0), vec3(60, -30, 0), vec3(60, 40, 0), vec3(-60, 40, 0), vec3(-60, -30, 0), vec3(-40, -30, 0), vec3(-20, -20, 0), vec3(-20, 0, 0) ] self.assertTrue(pym.bnrm(fp).isnear(vec3(0, 0, 1))) self.assertTrue(pym.bnrm(fp[::-1]).isnear(vec3(0, 0, -1))) fp = [ vec3(-282.1204528808594, 127.64604187011719, 0.0), vec3(-334.1018981933594, 179.6274871826172, 0.0), vec3(-130.43038940429688, 179.62747192382812, 0.0), vec3(-130.43038940429688, 336.434326171875, 0.0), vec3(-36.91655731201172, 366.8188171386719, 0.0), vec3(-36.916534423828125, 461.72088623046875, 0.0), vec3(191.35768127441406, 461.841796875, 0.0), vec3(275.3216552734375, 373.85748291015625, 0.0), vec3(152.47915649414062, 204.779296875, 0.0), vec3(332.7578430175781, -43.35302734375, 0.0), vec3(454.96630859375, -3.6450958251953125, 0.0), vec3(456.61492919921875, -166.4105224609375, 0.0), vec3(316.5687561035156, -120.90676879882812, 0.0), vec3(201.97442626953125, -278.63232421875, 0.0), vec3(277.8673400878906, -383.0899963378906, 0.0), vec3(195.58241271972656, -472.19598388671875, 0.0), vec3(-10.369781494140625, -468.9277038574219, 0.0), vec3(-10.369804382324219, -395.02154541015625, 0.0), vec3(-78.82841491699219, -326.56292724609375, 0.0), vec3(-175.64352416992188, -326.56292724609375, 0.0), vec3(-244.10214233398438, -395.0215759277344, 0.0), vec3(-244.10214233398438, -414.89117431640625, 0.0), vec3(-465.6239929199219, -192.85736083984375, 0.0), vec3(-466.0299072265625, -122.715087890625, 0.0), vec3(-385.8233947753906, -122.71507263183594, 0.0), vec3(-282.1204528808594, -19.01211929321289, 0.0), ] bn = pym.bnrm(fp) print('bnnn', bn) fp.reverse() pl() bn = pym.bnrm(fp) print('bnnnrev', bn) self.assertTrue(pym.bnrm(fp).isnear(vec3(0, 0, 1))) self.assertTrue(pym.bnrm(fp[::-1]).isnear(vec3(0, 0, -1)))
def pl(b1, b2): ax = dtl.plot_axes_xy(10) ax = dtl.plot_polygon_xy(b1, ax, lw=2.0, col='g') ax = dtl.plot_polygon_xy(b2, ax, lw=2.0, col='b') plt.show()
def pl(): ax = dtl.plot_axes_xy(700) ax = dtl.plot_polygon_xy(fp, ax, lw=2, col='g') ax = dtl.plot_points_xy(fp, ax, number=True) plt.show()
def pinchb(b, epsilon=5): pde = lambda p, e1, e2: abs() new = lambda s1, s2: not ((s1, s2) in unfin or (s1, s2) in unfin) unfin = [(b[x - 1], b[x]) for x in range(len(b))] fin = [] while unfin: u1, u2 = unfin.pop(0) clear = True for e1, e2 in unfin: e1u12d = e1.dexy(u1, u2, 0) e2u12d = e2.dexy(u1, u2, 0) if False and e1u12d > -1 and e1u12d < epsilon: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b, ax, lw=2, ls='--', col='k') ax = dtl.plot_edges_xy((u1, u2), ax, lw=3, col='b') ax = dtl.plot_edges_xy((e1, e2), ax, lw=3, col='g') plt.show() pdb.set_trace() elif False and e2u12d > -1 and e2u12d < epsilon: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b, ax, lw=2, ls='--', col='k') ax = dtl.plot_edges_xy((u1, u2), ax, lw=3, col='b') ax = dtl.plot_edges_xy((e1, e2), ax, lw=3, col='g') plt.show() pdb.set_trace() elif e1.onsxy(u1, u2, 0): if new(u1, e1): unfin.append((u1, e1)) if new(e1, u2): unfin.append((e1, u2)) clear = False break elif e2.onsxy(u1, u2, 0): if new(u1, e2): unfin.append((u1, e2)) if new(e2, u2): unfin.append((e2, u2)) clear = False break elif sintsxy(u1, u2, e1, e2, ie=False, ieb=False): '''# ax = dtl.plot_axes_xy(200) for u in unfin: ax = dtl.plot_edges_xy(u,ax,col = 'r',lw = 8) for f in fin: ax = dtl.plot_edges_xy(f,ax,col = 'g',lw = 7) ax = dtl.plot_edges_xy((u1,u2),ax,col = 'c',lw = 5) ax = dtl.plot_edges_xy((e1,e2),ax,col = 'b',lw = 2) plt.show() '''# if sintsxy(u1, u2, e1, e2, ie=False, ieb=False, col=False): ip = sintsxyp(u1, u2, e1, e2) if new(u1, ip): unfin.append((u1, ip)) if new(ip, u2): unfin.append((ip, u2)) clear = False break else: if new(u1, u2): unfin.append((u1, u2)) clear = False if clear: fin.append((u1, u2)) uloops = sloops(fin, epsilon) if len(uloops) > 1: #las = [bareaxy(ol) for ol in uloops] las = [bareaxy(ol, True) for ol in uloops] ulas = [(u, a) for u, a in zip(uloops, las) if a > 10] if ulas: uloops, las = zip(*ulas) uloops, las = list(uloops), list(las) uloops.insert(0, uloops.pop(las.index(max(las)))) print('PINCHB ACCOMPLISHED') return uloops
def pinchb(b,epsilon = 5): pde = lambda p,e1,e2 : abs() new = lambda s1,s2 : not ((s1,s2) in unfin or (s1,s2) in unfin) unfin = [(b[x-1],b[x]) for x in range(len(b))] fin = [] while unfin: u1,u2 = unfin.pop(0) clear = True for e1,e2 in unfin: e1u12d = e1.dexy(u1,u2,0) e2u12d = e2.dexy(u1,u2,0) if False and e1u12d > -1 and e1u12d < epsilon: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b,ax,lw = 2,ls = '--',col = 'k') ax = dtl.plot_edges_xy((u1,u2),ax,lw = 3,col = 'b') ax = dtl.plot_edges_xy((e1,e2),ax,lw = 3,col = 'g') plt.show() pdb.set_trace() elif False and e2u12d > -1 and e2u12d < epsilon: ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(b,ax,lw = 2,ls = '--',col = 'k') ax = dtl.plot_edges_xy((u1,u2),ax,lw = 3,col = 'b') ax = dtl.plot_edges_xy((e1,e2),ax,lw = 3,col = 'g') plt.show() pdb.set_trace() elif e1.onsxy(u1,u2,0): if new(u1,e1):unfin.append((u1,e1)) if new(e1,u2):unfin.append((e1,u2)) clear = False break elif e2.onsxy(u1,u2,0): if new(u1,e2):unfin.append((u1,e2)) if new(e2,u2):unfin.append((e2,u2)) clear = False break elif sintsxy(u1,u2,e1,e2,ie = False,ieb = False): '''# ax = dtl.plot_axes_xy(200) for u in unfin: ax = dtl.plot_edges_xy(u,ax,col = 'r',lw = 8) for f in fin: ax = dtl.plot_edges_xy(f,ax,col = 'g',lw = 7) ax = dtl.plot_edges_xy((u1,u2),ax,col = 'c',lw = 5) ax = dtl.plot_edges_xy((e1,e2),ax,col = 'b',lw = 2) plt.show() '''# if sintsxy(u1,u2,e1,e2,ie = False,ieb = False,col = False): ip = sintsxyp(u1,u2,e1,e2) if new(u1,ip):unfin.append((u1,ip)) if new(ip,u2):unfin.append((ip,u2)) clear = False break else: if new(u1,u2):unfin.append((u1,u2)) clear = False if clear: fin.append((u1,u2)) uloops = sloops(fin,epsilon) if len(uloops) > 1: #las = [bareaxy(ol) for ol in uloops] las = [bareaxy(ol,True) for ol in uloops] ulas = [(u,a) for u,a in zip(uloops,las) if a > 10] if ulas: uloops,las = zip(*ulas) uloops,las = list(uloops),list(las) uloops.insert(0,uloops.pop(las.index(max(las)))) print('PINCHB ACCOMPLISHED') return uloops
def pl(b1,b2,br): ax = dtl.plot_axes_xy(20) ax = dtl.plot_polygon_xy(b1,ax,col = 'b',lw = 5.0) ax = dtl.plot_polygon_xy(b2,ax,col = 'g',lw = 5.0) for b in br:ax = dtl.plot_polygon_xy(b,ax,col = 'r',lw = 2.0) plt.show()
def plot(self,l,sx,sy): sq = vec3(0,0,0).sq(sx,sy) ax = dtl.plot_axes_xy(10) ax = dtl.plot_polygon_xy(sq,ax,lw = 1,col = 'r') ax = dtl.plot_polygon_full_xy(l,ax,lw = 2,col = 'g') plt.show()
def pl(s1,s2,b): ax = dtl.plot_axes_xy() ax = dtl.plot_polygon_xy(b,ax,lw = 2.0,col = 'g') ax = dtl.plot_edges_xy([s1,s2],ax,lw = 4.0,col = 'b') plt.show()
def pl(): ax = dtl.plot_axes_xy(700) ax = dtl.plot_polygon_xy(fp,ax,lw = 2,col = 'g') ax = dtl.plot_points_xy(fp,ax,number = True) plt.show()
def test_sintbxyp(self): u1,u2 = (vec3(77.000000,33.001942,0.000000) , vec3(63.000000,33.000004,0.000000)) b = [ vec3(75.000000,35.000011,0.000000) , vec3(76.999992,35.000011,0.000000) , vec3(76.999992,32.999996,0.000000) , vec3(67.000000,33.000000,0.000000) , vec3(66.999992,22.999996,0.000000) , vec3(33.000000,23.000004,0.000000) , vec3(33.000000,33.001392,0.000000) , vec3(23.001953,33.000004,0.000000) , vec3(23.001545,61.998047,0.000000) , vec3(23.001442,63.001602,0.000000) , vec3(18.000002,63.001541,0.000000) , vec3(16.999865,63.001438,0.000000) , vec3(17.000000,62.000000,0.000000) , vec3(17.000000,58.000000,0.000000) , vec3(17.000000,42.000000,0.000000) , vec3(17.000000,38.000000,0.000000) , vec3(17.000000,18.000000,0.000000) , vec3(5.000000,18.000000,0.000000) , vec3(5.000000,20.000000,0.000000) , vec3(5.000000,38.000000,0.000000) , vec3(5.000000,40.000000,0.000000) , vec3(5.000000,42.000000,0.000000) , vec3(5.000000,58.000000,0.000000) , vec3(5.000000,60.000000,0.000000) , vec3(5.000000,62.000000,0.000000) , vec3(5.000000,63.000206,0.000000) , vec3(5.000000,75.000000,0.000000) , vec3(16.998253,75.000000,0.000000) , vec3(17.999998,75.000000,0.000000) , vec3(19.999998,75.000000,0.000000) , vec3(22.000002,75.000000,0.000000) , vec3(23.000202,75.000000,0.000000) , vec3(34.999996,75.000000,0.000000) , vec3(34.999996,63.001747,0.000000) , vec3(34.999996,61.999722,0.000000) , vec3(34.999996,60.000000,0.000000) , vec3(34.999996,58.000000,0.000000) , vec3(35.000000,36.999996,0.000000) , vec3(35.000000,35.000004,0.000000) , vec3(36.999866,35.000000,0.000000) , vec3(63.000004,35.000004,0.000000) , vec3(64.999992,35.000004,0.000000) , vec3(64.999992,37.000004,0.000000) , vec3(64.999992,43.001785,0.000000) , vec3(64.999992,45.000004,0.000000) , vec3(62.999996,45.000004,0.000000) , vec3(56.999790,45.000004,0.000000) , vec3(44.999996,45.000000,0.000000) , vec3(44.999996,56.998211,0.000000) , vec3(44.999996,58.000000,0.000000) , vec3(44.999996,60.000000,0.000000) , vec3(44.999996,62.000000,0.000000) , vec3(45.000000,63.000206,0.000000) , vec3(45.000000,75.000000,0.000000) , vec3(57.000000,75.000000,0.000000) , vec3(57.999996,75.000000,0.000000) , vec3(59.999992,75.000000,0.000000) , vec3(62.000004,75.000000,0.000000) , vec3(63.000195,75.000000,0.000000) , vec3(74.999985,75.000000,0.000000) , vec3(74.999985,63.001747,0.000000) , vec3(74.999985,60.000004,0.000000) , vec3(74.999985,57.999996,0.000000) , vec3(63.001968,58.000004,0.000000) , vec3(63.001446,63.000515,0.000000) , vec3(58.000008,63.000000,0.000000) , vec3(56.998913,63.001442,0.000000) , vec3(56.998459,58.000004,0.000000) , vec3(56.998562,56.999187,0.000000) , vec3(67.000008,57.000004,0.000000) , vec3(67.000000,47.000000,0.000000) , vec3(74.999992,47.000004,0.000000) , ] ips = pym.sintbxyp(u1,u2,b,ieb = False) ax = dtl.plot_axes_xy(100) ax = dtl.plot_polygon_xy(b,ax,lw = 2,col = 'g') ax = dtl.plot_points_xy((u1,u2),ax,cs = ['b']*2) ax = dtl.plot_edges_xy((u1,u2),ax,col = 'b') ax = dtl.plot_points_xy(ips,ax,cs = ['r']*len(ips)) print('IPS',ips) plt.show() pdb.set_trace()
def pl(b1,b2): ax = dtl.plot_axes_xy(10) ax = dtl.plot_polygon_xy(b1,ax,lw = 2.0,col = 'g') ax = dtl.plot_polygon_xy(b2,ax,lw = 2.0,col = 'b') plt.show()
def pl(b): ax = dtl.plot_axes_xy(300) ax = dtl.plot_polygon_xy(b,ax) plt.show()
def pl(b): ax = dtl.plot_axes_xy(300) ax = dtl.plot_polygon_xy(b, ax) plt.show()
def pv(v,ax): ax = dtl.plot_polygon_xy(v.loop,ax,lw = 2) #for c in self.looptree.below(v):pv(c,ax) for c in self.below(v):pv(c,ax)
def test_bnrm(self): def pl(): ax = dtl.plot_axes_xy(700) ax = dtl.plot_polygon_xy(fp,ax,lw = 2,col = 'g') ax = dtl.plot_points_xy(fp,ax,number = True) plt.show() ebnd = db.persistent_container('/home/cogle/dev/dilapidator/test/','ebnd') ebnd.load() ebnd = ebnd.data ax = dtl.plot_axes_xy(120) ax = dtl.plot_polygon_xy(ebnd,ax,lw = 4,col = 'r') ax = dtl.plot_points_xy(ebnd,ax,number = True) plt.show() fp = [ vec3(-6.9831085205078125, 121.9827880859375, 0.0), vec3(-26.983108520507812, 121.9827880859375, 0.0), vec3(-46.98310852050781, 121.9827880859375, 0.0), vec3(-66.98310852050781, 121.9827880859375, 0.0), vec3(-85.984375, 121.9827880859375, 0.0), vec3(-85.98310852050781, 102.9827880859375, 0.0), vec3(-85.98310852050781, 82.9827880859375, 0.0), vec3(-85.98310852050781, 63.9814453125, 0.0), vec3(-66.98310852050781, 63.9827880859375, 0.0), vec3(-46.98310852050781, 63.9827880859375, 0.0), vec3(-26.983108520507812, 63.9827880859375, 0.0), vec3(-6.9831085205078125, 63.9827880859375, 0.0), vec3(13.016891479492188, 63.9827880859375, 0.0), vec3(33.01689147949219, 63.9827880859375, 0.0), vec3(53.01689147949219, 63.9827880859375, 0.0), vec3(73.01689147949219, 63.9827880859375, 0.0), vec3(93.01689147949219, 63.9827880859375, 0.0), vec3(112.017578125, 63.9827880859375, 0.0), vec3(112.01689147949219, 82.9827880859375, 0.0), vec3(112.01689147949219, 102.9827880859375, 0.0), vec3(112.01689147949219, 121.9833984375, 0.0), vec3(93.01689147949219, 121.9827880859375, 0.0), vec3(73.01689147949219, 121.9827880859375, 0.0), vec3(53.01689147949219, 121.9827880859375, 0.0), vec3(33.01689147949219, 121.9827880859375, 0.0), vec3(13.016891479492188, 121.9827880859375, 0.0)] ax = dtl.plot_axes_xy(200) ax = dtl.plot_polygon_xy(fp,ax,lw = 3,col = 'b') ax = dtl.plot_points_xy(fp,ax,number = True) plt.show() self.assertTrue(pym.bnrm(fp).isnear(vec3(0,0,1))) vb = vec3(-100,100,0).sq(400,400) dx,dy,xn,yn = 20,20,10,30 o = vec3(-dx*xn/2.0,-dy*yn,0).com(vb) vgrid = [o.cp().trn(vec3(x*dx,y*dy,0)) for y in range(yn) for x in range(xn)] boxes = [p.sq(dx,dy) for p in vgrid] boxes = [b for b in boxes if pym.binbxy(b,vb)] box = pym.bsuxy(boxes) self.assertTrue(pym.bnrm(box[0]).isnear(vec3(0,0,1))) fp = [vec3(0,0,0), vec3(20,0,0),vec3(20,-20,0),vec3(40,-30,0),vec3(60,-30,0), vec3(60,40,0),vec3(-60,40,0),vec3(-60,-30,0),vec3(-40,-30,0), vec3(-20,-20,0),vec3(-20,0,0)] self.assertTrue(pym.bnrm(fp).isnear(vec3(0,0,1))) self.assertTrue(pym.bnrm(fp[::-1]).isnear(vec3(0,0,-1))) fp = [ vec3(-282.1204528808594, 127.64604187011719, 0.0), vec3(-334.1018981933594, 179.6274871826172, 0.0), vec3(-130.43038940429688, 179.62747192382812, 0.0), vec3(-130.43038940429688, 336.434326171875, 0.0), vec3(-36.91655731201172, 366.8188171386719, 0.0), vec3(-36.916534423828125, 461.72088623046875, 0.0), vec3(191.35768127441406, 461.841796875, 0.0), vec3(275.3216552734375, 373.85748291015625, 0.0), vec3(152.47915649414062, 204.779296875, 0.0), vec3(332.7578430175781, -43.35302734375, 0.0), vec3(454.96630859375, -3.6450958251953125, 0.0), vec3(456.61492919921875, -166.4105224609375, 0.0), vec3(316.5687561035156, -120.90676879882812, 0.0), vec3(201.97442626953125, -278.63232421875, 0.0), vec3(277.8673400878906, -383.0899963378906, 0.0), vec3(195.58241271972656, -472.19598388671875, 0.0), vec3(-10.369781494140625, -468.9277038574219, 0.0), vec3(-10.369804382324219, -395.02154541015625, 0.0), vec3(-78.82841491699219, -326.56292724609375, 0.0), vec3(-175.64352416992188, -326.56292724609375, 0.0), vec3(-244.10214233398438, -395.0215759277344, 0.0), vec3(-244.10214233398438, -414.89117431640625, 0.0), vec3(-465.6239929199219, -192.85736083984375, 0.0), vec3(-466.0299072265625, -122.715087890625, 0.0), vec3(-385.8233947753906, -122.71507263183594, 0.0), vec3(-282.1204528808594, -19.01211929321289, 0.0), ] bn = pym.bnrm(fp) print('bnnn',bn) fp.reverse() pl() bn = pym.bnrm(fp) print('bnnnrev',bn) self.assertTrue(pym.bnrm(fp).isnear(vec3(0,0,1))) self.assertTrue(pym.bnrm(fp[::-1]).isnear(vec3(0,0,-1)))