コード例 #1
0
    def atest_polygon(self):
        def pl():
            ax = dtl.plot_axes_xy(50)
            ax = dtl.plot_polygon_full_xy(py,ax,lw = 2,col = 'b')
            plt.show()

        rg = pgr.planargraph()

        i1 = rg.av(p = vec3( 10,-5,0),l = 0)
        i2 = rg.av(p = vec3( 10, 5,0),l = 0)
        i3 = rg.av(p = vec3(-10, 5,0),l = 0)
        i4 = rg.av(p = vec3(-10,-5,0),l = 0)
        r1 = rg.ae(i1,i2)
        r2 = rg.ae(i2,i3)
        r3 = rg.ae(i3,i4)
        r4 = rg.ae(i4,i1)
        i5 = rg.av(p = vec3(2,-10,0),l = 0)
        r5,r6 = rg.se(i1,i4,i5)
        i6 = rg.av(p = vec3(-2,10,0),l = 0)
        r7,r8 = rg.se(i2,i3,i6)
        r9 = rg.ae(i5,i6)
        i7,r10 = rg.mev(i1,{'p':vec3(12,-20,0),'l':0},{})
        i8,r11 = rg.mev(i3,{'p':vec3(-5,0,0),'l':0},{})
        i9,r12 = rg.mev(i7,{'p':vec3(14,-28,0),'l':0},{})

        py = pym.pgtopy(rg,2)
        pl()
コード例 #2
0
ファイル: lsystem_tests.py プロジェクト: ctogle/dilapidator
    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()
コード例 #3
0
    def atest_polygon(self):
        def pl():
            ax = dtl.plot_axes_xy(50)
            ax = dtl.plot_polygon_full_xy(py, ax, lw=2, col='b')
            plt.show()

        rg = pgr.planargraph()

        i1 = rg.av(p=vec3(10, -5, 0), l=0)
        i2 = rg.av(p=vec3(10, 5, 0), l=0)
        i3 = rg.av(p=vec3(-10, 5, 0), l=0)
        i4 = rg.av(p=vec3(-10, -5, 0), l=0)
        r1 = rg.ae(i1, i2)
        r2 = rg.ae(i2, i3)
        r3 = rg.ae(i3, i4)
        r4 = rg.ae(i4, i1)
        i5 = rg.av(p=vec3(2, -10, 0), l=0)
        r5, r6 = rg.se(i1, i4, i5)
        i6 = rg.av(p=vec3(-2, 10, 0), l=0)
        r7, r8 = rg.se(i2, i3, i6)
        r9 = rg.ae(i5, i6)
        i7, r10 = rg.mev(i1, {'p': vec3(12, -20, 0), 'l': 0}, {})
        i8, r11 = rg.mev(i3, {'p': vec3(-5, 0, 0), 'l': 0}, {})
        i9, r12 = rg.mev(i7, {'p': vec3(14, -28, 0), 'l': 0}, {})

        py = pym.pgtopy(rg, 2)
        pl()
コード例 #4
0
ファイル: lsystem_tests.py プロジェクト: ctogle/dilapidator
    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()
コード例 #5
0
ファイル: blockletters.py プロジェクト: ctogle/dilapidator
def letter(l,w,sx,sy):
    if w > sx or w > sy:raise ValueError
    sq = vec3(0,0,0).sq(sx-w,sy-w)
    g = pgr.planargraph()
    if   l == 'C':C(sq,g)
    elif l == 'H':H(sq,g)
    elif l == 'I':I(sq,g)
    return g
コード例 #6
0
def letter(l, w, sx, sy):
    if w > sx or w > sy: raise ValueError
    sq = vec3(0, 0, 0).sq(sx - w, sy - w)
    g = pgr.planargraph()
    if l == 'C': C(sq, g)
    elif l == 'H': H(sq, g)
    elif l == 'I': I(sq, g)
    return g
コード例 #7
0
    def atest_uloops(self):
        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()

        rg = pgr.planargraph()
        i1 = rg.av(p=vec3(10, -5, 0), l=0)
        i2 = rg.av(p=vec3(10, 5, 0), l=0)
        i3 = rg.av(p=vec3(-10, 5, 0), l=0)
        i4 = rg.av(p=vec3(-10, -5, 0), l=0)
        r1 = rg.ae(i1, i2)
        r2 = rg.ae(i2, i3)
        r3 = rg.ae(i3, i4)
        r4 = rg.ae(i4, i1)
        i5 = rg.av(p=vec3(2, -10, 0), l=0)
        r5, r6 = rg.se(i1, i4, i5)
        i6 = rg.av(p=vec3(-2, 10, 0), l=0)
        r7, r8 = rg.se(i2, i3, i6)
        r9 = rg.ae(i5, i6)
        loops = rg.uloops('ccw')

        #pl()
        self.assertEqual(len(loops), 3)

        i7, r10 = rg.mev(i1, {'p': vec3(12, -20, 0), 'l': 0}, {})
        loops = rg.uloops('ccw')

        #pl()
        self.assertEqual(len(loops), 3)

        b1 = vec3(-4, 0, 0).pring(4, 8)
        b2 = vec3(2, 2, 0).pring(4, 8)
        b1segs = pym.bsegbxy(b1, b2)
        b2segs = pym.bsegbxy(b2, b1)
        rg = pym.sstopg(b1segs + b2segs)
        loops = rg.uloops('ccw')
        #pl()

        b = [
            vec3(-320.2890319824219, 72.00794982910156, 40.000003814697266),
            vec3(-299.5256042480469, 72.07875061035156, 40.000003814697266),
            vec3(-299.5280456542969, 91.03677368164062, 40.000003814697266),
            vec3(-299.5280456542969, 129.9380645751953, 40.000003814697266),
            vec3(-299.5280456542969, 135.1514129638672, 40.000003814697266),
            vec3(-299.5280456542969, 138.2604522705078, 40.000003814697266),
            vec3(-292.4235534667969, 147.1795654296875, 40.000003814697266),
            vec3(-305.3035583496094, 125.37327575683594, 40.000003814697266),
            vec3(-312.3858947753906, 99.95317077636719, 40.000003814697266),
        ]
        bsegs = [(b[j - 1], b[j]) for j in range(len(b))]
        rg = pym.sstopg(bsegs)
        loops = rg.uloops('ccw')
        print('itsher')
        pl()
コード例 #8
0
    def atest_uloops(self):
        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()
        rg = pgr.planargraph()
        i1 = rg.av(p = vec3( 10,-5,0),l = 0)
        i2 = rg.av(p = vec3( 10, 5,0),l = 0)
        i3 = rg.av(p = vec3(-10, 5,0),l = 0)
        i4 = rg.av(p = vec3(-10,-5,0),l = 0)
        r1 = rg.ae(i1,i2)
        r2 = rg.ae(i2,i3)
        r3 = rg.ae(i3,i4)
        r4 = rg.ae(i4,i1)
        i5 = rg.av(p = vec3(2,-10,0),l = 0)
        r5,r6 = rg.se(i1,i4,i5)
        i6 = rg.av(p = vec3(-2,10,0),l = 0)
        r7,r8 = rg.se(i2,i3,i6)
        r9 = rg.ae(i5,i6)
        loops = rg.uloops('ccw')

        #pl()
        self.assertEqual(len(loops),3)

        i7,r10 = rg.mev(i1,{'p':vec3(12,-20,0),'l':0},{})
        loops = rg.uloops('ccw')

        #pl()
        self.assertEqual(len(loops),3)

        b1 = vec3(-4,0,0).pring(4,8)
        b2 = vec3(2,2,0).pring(4,8)
        b1segs = pym.bsegbxy(b1,b2)
        b2segs = pym.bsegbxy(b2,b1)
        rg = pym.sstopg(b1segs+b2segs)
        loops = rg.uloops('ccw')
        #pl()

        b = [
            vec3(-320.2890319824219, 72.00794982910156, 40.000003814697266),
            vec3(-299.5256042480469, 72.07875061035156, 40.000003814697266),
            vec3(-299.5280456542969, 91.03677368164062, 40.000003814697266),
            vec3(-299.5280456542969, 129.9380645751953, 40.000003814697266),
            vec3(-299.5280456542969, 135.1514129638672, 40.000003814697266),
            vec3(-299.5280456542969, 138.2604522705078, 40.000003814697266),
            vec3(-292.4235534667969, 147.1795654296875, 40.000003814697266),
            vec3(-305.3035583496094, 125.37327575683594, 40.000003814697266),
            vec3(-312.3858947753906, 99.95317077636719, 40.000003814697266),
                ]
        bsegs = [(b[j-1],b[j]) for j in range(len(b))]
        rg = pym.sstopg(bsegs)
        loops = rg.uloops('ccw')
        print('itsher')
        pl()
コード例 #9
0
ファイル: roadgraph_tests.py プロジェクト: ctogle/dilapidator
    def test_checkseq(self):

        fp = vec3(0,0,0).pring(100,5)
        seq = 'S<>G<>L<>'
        
        rg = pgr.planargraph()
        rg = rdg.checkseq(rg,fp,seq,True)

        ax = rg.plot()
        plt.show()
コード例 #10
0
ファイル: roadgraph_tests.py プロジェクト: ctogle/dilapidator
    def test_checkseq(self):

        fp = vec3(0, 0, 0).pring(100, 5)
        seq = 'S<>G<>L<>'

        rg = pgr.planargraph()
        rg = rdg.checkseq(rg, fp, seq, True)

        ax = rg.plot()
        plt.show()
コード例 #11
0
def sstopg(segs, epsilon=0.1, plot=False):
    g = pgr.planargraph()
    for e1, e2 in segs:
        v1, v2 = g.fp(e1, epsilon), g.fp(e2, epsilon)
        if v1 == v2: pass  #print('seg is smaller than epsilon')
        elif not v2 in g.rings[v1]: g.fe(v1, v2)
        elif not v1 in g.rings[v2]: g.fe(v2, v1)
    if plot:
        ax = g.plotxy(l=500)
        plt.show()
    return g
コード例 #12
0
ファイル: polymath.py プロジェクト: ctogle/dilapidator
def sstopg(segs,epsilon = 0.1,plot = False):
    g = pgr.planargraph()
    for e1,e2 in segs:
        v1,v2 = g.fp(e1,epsilon),g.fp(e2,epsilon)
        if v1 == v2:pass#print('seg is smaller than epsilon')
        elif not v2 in g.rings[v1]:g.fe(v1,v2)
        elif not v1 in g.rings[v2]:g.fe(v2,v1)
    if plot:
        ax = g.plotxy(l = 500)
        plt.show()
    return g
コード例 #13
0
    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
コード例 #14
0
ファイル: lsystem_tests.py プロジェクト: ctogle/dilapidator
    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()
コード例 #15
0
    def atest_orings(self):
        rg = pgr.planargraph()

        i1 = rg.av(p = vec3(  0, 0,0),l = 0)
        i2 = rg.av(p = vec3( 10, 0,0),l = 0)
        i3 = rg.av(p = vec3(-10, 0,0),l = 0)
        i4 = rg.av(p = vec3(  0,10,0),l = 0)

        r1 = rg.ae(i1,i2)
        r2 = rg.ae(i1,i3)
        r3 = rg.ae(i1,i4)

        self.assertEqual(rg.orings[0],[1,3,2])
        if False:
            ax = rg.plot()
            plt.show()
コード例 #16
0
    def atest_orings(self):
        rg = pgr.planargraph()

        i1 = rg.av(p=vec3(0, 0, 0), l=0)
        i2 = rg.av(p=vec3(10, 0, 0), l=0)
        i3 = rg.av(p=vec3(-10, 0, 0), l=0)
        i4 = rg.av(p=vec3(0, 10, 0), l=0)

        r1 = rg.ae(i1, i2)
        r2 = rg.ae(i1, i3)
        r3 = rg.ae(i1, i4)

        self.assertEqual(rg.orings[0], [1, 3, 2])
        if False:
            ax = rg.plot()
            plt.show()
コード例 #17
0
    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()
コード例 #18
0
ファイル: terrain.py プロジェクト: ctogle/dilapidator
    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
コード例 #19
0
ファイル: polymath_tests.py プロジェクト: ctogle/dilapidator
    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()
コード例 #20
0
ファイル: lsystem_tests.py プロジェクト: ctogle/dilapidator
    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()
コード例 #21
0
    def atest_mev(self):
        def pl():
            ax = rg.plot()
            ax = dtl.plot_polygon(fp, ax, col='b')
            ax = dtl.plot_point(ex, ax, col='r')
            plt.show()

        p1 = vec3(100, 0, 0)
        p2 = vec3(0, 100, 0)
        p3 = vec3(100, 100, 0)

        rg = pgr.planargraph()

        i1 = rg.av(p=p1, l=0)
        i2, r1 = rg.mev(i1, {'p': p2, 'l': 0}, {})
        i3, r2 = rg.mev(i2, {'p': p3, 'l': 0}, {})

        if False: pl()
コード例 #22
0
    def atest_mev(self):
        def pl():
            ax = rg.plot()
            ax = dtl.plot_polygon(fp,ax,col = 'b')
            ax = dtl.plot_point(ex,ax,col = 'r')
            plt.show()

        p1 = vec3(100,0,0)
        p2 = vec3(0,100,0)
        p3 = vec3(100,100,0)

        rg = pgr.planargraph()

        i1 = rg.av(p = p1,l = 0)
        i2,r1 = rg.mev(i1,{'p':p2,'l':0},{})
        i3,r2 = rg.mev(i2,{'p':p3,'l':0},{})

        if False:pl()
コード例 #23
0
ファイル: partitiongraph.py プロジェクト: ctogle/dilapidator
    def bgraph(self,epsilon = 0.1):
        bg = pgr.planargraph()
        for vx in range(self.vcnt):
            v = self.vs[vx]
            if v is None:continue
            eb = v[1]['b'][0]

            '''#
            # check if intersections happen in between!
            fnd = True
            while fnd:
                fnd = False
                for ox in range(self.vcnt):
                    o = self.vs[ox]
                    if o is None or ox == vx:continue
                    ob = o[1]['b'][0]
                    adjs = pym.badjbxy(eb,ob,0.1)
                    acnt = len(adjs)
                    if acnt == 0:continue
                    else:
                        if acnt > 1:print('multiadjacency!!')
                        for adj in adjs:
                            vbx,obx = adj
                            vb1,vb2 = eb[vbx-1],eb[vbx]
                            ob1,ob2 = ob[obx-1],ob[obx]
                            ips = pym.sintsxyp(vb1,vb2,ob1,ob2,ieb = 0,skew = 0,ie = 0)
                            if ips is None:continue
                            ip1,ip2 = ips
                            if not ip1 in eb or not ip2 in eb:
                                if ip1.onsxy(vb1,vb2,0):
                                    eb.insert(vbx,ip1);fnd = True
                                if ip2.onsxy(vb1,vb2,0):
                                    eb.insert(vbx,ip2);fnd = True
                        if fnd:break
            '''#

            for ebx in range(len(eb)):
                e1,e2 = eb[ebx-1],eb[ebx]
                v1,v2 = bg.fp(e1,epsilon),bg.fp(e2,epsilon)
                if not v2 in bg.rings[v1]:bg.ae(v1,v2)

        return bg
コード例 #24
0
    def layroads(t, e):
        '''generate a planargraph of a network of roads'''

        #return pgr.planargraph()

        drho, i = 20, 3
        p, d = vec3(0, 0, 0), vec3(0, 1, 0)
        #axiom = 'X'
        #rules = dict([('X','F{[X}{]X}X'),('F','FF')])
        #params = dict(dazimuthal = gtl.rad(90),drho = drho)
        axiom = 'X'
        rules = dict([('X', 'F]{{X}[X}[F{[FX}]X'), ('F', 'FF')])
        params = dict(dazimuthal=gtl.rad(90), drho=drho)
        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, drho / 2), pg.fp(p2, drho / 2)
                rdkws = {'style': 'urban'}
                e12 = pg.fe(v1, v2, **rdkws)
            elif isinstance(piece, vec3):
                pass

        #for v in pg.vs:
        #    if v is None:continue
        #    p = v[1]['p']
        #    p.ztrn(t(p.x,p.y))

        #pyscale = vec3(0,1,0).prjps(py)
        #tipscale = vec3(0,1,0).prjps(tip.loop)
        #pyscale = pyscale[1]-pyscale[0]
        #tipscale = tipscale[1]-tipscale[0]
        #scale = tipscale/pyscale
        #com = vec3(0,0,0).com(tip.loop).tov(vec3(0,0,0).com(py)).uscl(-1)
        #for p in py:p.scl(vec3(scale,scale,0)).trn(com)

        print('ROADS')
        ax = dtl.plot_axes_xy(200)
        ax = pg.plotxy(ax)
        plt.show()
        #pdb.set_trace()
        return pg
コード例 #25
0
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
コード例 #26
0
ファイル: polygen.py プロジェクト: ctogle/dilapidator
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
コード例 #27
0
    def atest_avrvaerese(self):

        rg = pgr.planargraph()

        i1 = rg.av(p = vec3( 10,-5,0),l = 0)
        i2 = rg.av(p = vec3( 10, 5,0),l = 0)
        i3 = rg.av(p = vec3(-10, 5,0),l = 0)
        i4 = rg.av(p = vec3(-10,-5,0),l = 0)

        r1 = rg.ae(i1,i2)
        r2 = rg.ae(i2,i3)
        r3 = rg.ae(i3,i4)
        r4 = rg.ae(i4,i1)

        r2 = rg.re(i2,i3)

        i5 = rg.av(p = vec3(2,-10,0),l = 0)
        r5,r6 = rg.se(i1,i4,i5)

        #i1 = rg.rv(i1)

        if False:
            ax = rg.plot()
            plt.show()
コード例 #28
0
    def atest_avrvaerese(self):

        rg = pgr.planargraph()

        i1 = rg.av(p=vec3(10, -5, 0), l=0)
        i2 = rg.av(p=vec3(10, 5, 0), l=0)
        i3 = rg.av(p=vec3(-10, 5, 0), l=0)
        i4 = rg.av(p=vec3(-10, -5, 0), l=0)

        r1 = rg.ae(i1, i2)
        r2 = rg.ae(i2, i3)
        r3 = rg.ae(i3, i4)
        r4 = rg.ae(i4, i1)

        r2 = rg.re(i2, i3)

        i5 = rg.av(p=vec3(2, -10, 0), l=0)
        r5, r6 = rg.se(i1, i4, i5)

        #i1 = rg.rv(i1)

        if False:
            ax = rg.plot()
            plt.show()
コード例 #29
0
    def atest_peninsula(self):
        def pl():
            ax = rg.plot()
            ax = dtl.plot_polygon(fp,ax,col = 'b')
            ax = dtl.plot_point(ex,ax,col = 'r')
            plt.show()

        # given a footprint, a point within the footprint, and a point
        # possibly within the footprint, return a point within the footprint
        # on the line segment between the two points
        def wfp(fp,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

        # given an intersection, make/find another intersection and add a road
        def mr(rg,fp,ix):
            i = rg.vs[ix]
            ip = i[1]['p']
            es = rg.rings[i[0]]
            oes = rg.orings[i[0]]
            oec = len(oes)

            if oec == 0:
                di = ip.tov(vec3(0,0,0).com(fp))
                p2 = ip.cp().trn(di)
                #p2 = wfp(fp,ip,p2)
                res = rg.mev(ix,{'p':p2,'l':0},{})
                
            elif oec == 1:
                op = rg.vs[oes[0]][1]['p']
                a = random.choice((-1,1))*numpy.pi/2.0
                q = quat(1,0,0,0).av(a,vec3(0,0,1))
                p2 = ip.cp().trn(op.tov(ip).rot(q))
                p2 = wfp(fp,ip,p2)
                res = rg.mev(ix,{'p':p2,'l':0},{})

            else:
                for x in range(1,len(oes)):
                    oeas = rg.ea(i[0],oes[x-1],oes[x])

                    print('oeoeoe',oeas)

                    #rg.vs[oes[0]][1]['p']

                #i2,r1 = rg.mev(i1,{'p':p2,'l':0},{})
                pdb.set_trace()

            return res



        # WOULD BE NICE:
        # given a graph, footprint, and position, and radius, 
        #   return an intersection within radius of position if it exists

        fp = vec3(0,0,0).pring(50,8)
        ex = fp[-2].mid(fp[-1])
        rg = pgr.planargraph()

        i1 = rg.av(p = ex,l = 0)
        i2,r1 = mr(rg,fp,i1)
        i3,r2 = mr(rg,fp,i2)
        i4,r3 = mr(rg,fp,i3)
        i5,r4 = mr(rg,fp,i4)
        i6,r5 = mr(rg,fp,i5)

        #i2,r1 = rg.mev(i1,{'p':p2,'l':0},{})

        if False:pl()
コード例 #30
0
    def _____genroadnetwork(self, t):
        p, d, i, axiom, rules = ((vec3(0, 0, 0), vec3(0, 1, 0), 5, 'X',
                                  dict([('X', '{[[F}{]A}A]F'), ('F', 'FA'),
                                        ('A', 'F')])))
        params = dict(dazimuthal=gtl.rad(45), drho=20)

        drho, i = 10, 5
        p, d = vec3(0, 0, 0), vec3(0, 1, 0)
        axiom = 'X'
        rules = dict([('X', 'F{[X}{]X}X'), ('F', 'FF')])
        params = dict(dazimuthal=gtl.rad(90), drho=drho)

        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, drho / 2), pg.fp(p2, drho / 2)
                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)

        print('ROOOOADDDS')
        ax = dtl.plot_axes_xy(200)
        ax = pg.plotxy(ax)
        #ax = dtl.plot_polygon_xy(py,ax,lw = 3)
        plt.show()

        pdb.set_trace()

        # need a graph that spans all landmasses of the continent
        # at boundaries of existing regions, line up the roads nicely
        # within existing regions, add more regions based on road graph
        # develop resulting regions as before

        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()
        for lm in t.looptree.below(t.root):
            fp = lm.loop

            #seq = 'S<>G<>L<>'
            #rg = rdg.checkseq(rg,fp,seq,False)

            easement = 20

            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, w=0)
            i2, r1 = rg.mev(i1, {'p': ex2, 'l': 0, 'w': 0.5}, {})

            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(20)
                np = op.cp().trn(nptn)
                np = trimtofp(op, np, easement)
                nv, nr = rg.mev(tip, {'p': np, 'l': 0, 'w': 1}, {})

            start = nv
            tip = start
            fp_relax = pym.aggregate(pym.contract(fp, 30), 30)
            #fp_relax = fp[:]
            for p_relax in fp_relax:
                nv, nr = rg.mev(tip, {'p': p_relax, 'l': 0, 'w': 1}, {})
                tip = nv
            ne = rg.ae(tip, start, **{})

            #ax = rg.plotxy(l = 220)
            #plt.show()
            rg.smooth_sticks(1, 0.5)
            #ax = rg.plotxy(l = 220)
            #plt.show()

            '''#
            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')
            plt.show()
            '''#

            #pdb.set_trace()

        for rgv in rg.vs:
            rgp = rgv[1]['p']
            rgp.ztrn(t(rgp.x, rgp.y))

        ax = rg.plot(l=220)
        plt.show()

        return rg
コード例 #31
0
    def atest_loop(self):
        def pl(il):
            ilp = [rg.vs[j][1]['p'] for j in il]
            ilp = pym.contract(ilp, 2.0)
            ax = rg.plot()
            ax = dtl.plot_polygon(ilp, ax, col='b', lw=4)
            plt.show()

        rg = pgr.planargraph()
        i1 = rg.av(p=vec3(10, -5, 0), l=0)
        i2 = rg.av(p=vec3(10, 5, 0), l=0)
        i3 = rg.av(p=vec3(-10, 5, 0), l=0)
        i4 = rg.av(p=vec3(-10, -5, 0), l=0)
        r1 = rg.ae(i1, i2)
        r2 = rg.ae(i2, i3)
        r3 = rg.ae(i3, i4)
        r4 = rg.ae(i4, i1)
        i5 = rg.av(p=vec3(2, -10, 0), l=0)
        r5, r6 = rg.se(i1, i4, i5)
        i6 = rg.av(p=vec3(-2, 10, 0), l=0)
        r7, r8 = rg.se(i2, i3, i6)
        r9 = rg.ae(i5, i6)

        il = rg.loop(i5, i6, 'cw')
        self.assertEqual(il, [i5, i6, i2, i1])
        #pl(il)
        il = rg.loop(i5, i6, 'ccw')
        self.assertEqual(il, [i5, i6, i3, i4])
        #pl(il)
        il = rg.loop(i5, i1, 'cw')
        self.assertEqual(il, [i5, i1, i2, i6, i3, i4])
        #pl(il)
        il = rg.loop(i5, i1, 'ccw')
        self.assertEqual(il, [i5, i1, i2, i6])
        #pl(il)
        il = rg.loop(i1, i5, 'cw')
        self.assertEqual(il, [i1, i5, i6, i2])
        #pl(il)

        i7, r10 = rg.mev(i1, {'p': vec3(12, -20, 0), 'l': 0}, {})

        il = rg.loop(i5, i6, 'cw')
        self.assertEqual(il, [i5, i6, i2, i1])
        #pl(il)
        il = rg.loop(i5, i6, 'ccw')
        self.assertEqual(il, [i5, i6, i3, i4])
        #pl(il)
        il = rg.loop(i7, i1, 'cw')
        self.assertEqual(il, [i7, i1, i2, i6, i3, i4, i5, i1])
        #pl(il)
        il = rg.loop(i7, i1, 'ccw')
        self.assertEqual(il, [i7, i1, i5, i4, i3, i6, i2, i1])
        #pl(il)

        i8, r11 = rg.mev(i3, {'p': vec3(-5, 0, 0), 'l': 0}, {})

        il = rg.loop(i3, i4, 'ccw')
        self.assertEqual(il, [i3, i4, i5, i6, i3, i8])
        #pl(il)
        il = rg.loop(i3, i4, 'cw')
        self.assertEqual(il, [i3, i4, i5, i1, i7, i1, i2, i6])
        #pl(il)

        b1 = vec3(-4, 0, 0).pring(4, 8)
        b2 = vec3(2, 2, 0).pring(4, 8)
        b1segs = pym.bsegbxy(b1, b2)
        b2segs = pym.bsegbxy(b2, b1)
        rg = pym.sstopg(b1segs + b2segs)
        il = rg.loop(3, 4, 'ccw')
        #pl(il)

        il = rg.loop(1, 2, 'ccw')
        #pl(il)

        #il = rg.loop(1,3,'ccw')
        #pl(il)

        il = rg.loop(2, 3, 'ccw')
        #pl(il)

        il = rg.loop(4, 5, 'ccw')
        #pl(il)

        il = rg.loop(5, 6, 'ccw')
        #pl(il)

        il = rg.loop(6, 7, 'ccw')
        #pl(il)

        il = rg.loop(7, 8, 'ccw')
コード例 #32
0
    def atest_peninsula(self):
        def pl():
            ax = rg.plot()
            ax = dtl.plot_polygon(fp, ax, col='b')
            ax = dtl.plot_point(ex, ax, col='r')
            plt.show()

        # given a footprint, a point within the footprint, and a point
        # possibly within the footprint, return a point within the footprint
        # on the line segment between the two points
        def wfp(fp, 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

        # given an intersection, make/find another intersection and add a road
        def mr(rg, fp, ix):
            i = rg.vs[ix]
            ip = i[1]['p']
            es = rg.rings[i[0]]
            oes = rg.orings[i[0]]
            oec = len(oes)

            if oec == 0:
                di = ip.tov(vec3(0, 0, 0).com(fp))
                p2 = ip.cp().trn(di)
                #p2 = wfp(fp,ip,p2)
                res = rg.mev(ix, {'p': p2, 'l': 0}, {})

            elif oec == 1:
                op = rg.vs[oes[0]][1]['p']
                a = random.choice((-1, 1)) * numpy.pi / 2.0
                q = quat(1, 0, 0, 0).av(a, vec3(0, 0, 1))
                p2 = ip.cp().trn(op.tov(ip).rot(q))
                p2 = wfp(fp, ip, p2)
                res = rg.mev(ix, {'p': p2, 'l': 0}, {})

            else:
                for x in range(1, len(oes)):
                    oeas = rg.ea(i[0], oes[x - 1], oes[x])

                    print('oeoeoe', oeas)

                    #rg.vs[oes[0]][1]['p']

                #i2,r1 = rg.mev(i1,{'p':p2,'l':0},{})
                pdb.set_trace()

            return res

        # WOULD BE NICE:
        # given a graph, footprint, and position, and radius,
        #   return an intersection within radius of position if it exists

        fp = vec3(0, 0, 0).pring(50, 8)
        ex = fp[-2].mid(fp[-1])
        rg = pgr.planargraph()

        i1 = rg.av(p=ex, l=0)
        i2, r1 = mr(rg, fp, i1)
        i3, r2 = mr(rg, fp, i2)
        i4, r3 = mr(rg, fp, i3)
        i5, r4 = mr(rg, fp, i4)
        i6, r5 = mr(rg, fp, i5)

        #i2,r1 = rg.mev(i1,{'p':p2,'l':0},{})

        if False: pl()
コード例 #33
0
    def atest_loop(self):
        def pl(il):
            ilp = [rg.vs[j][1]['p'] for j in il]
            ilp = pym.contract(ilp,2.0)
            ax = rg.plot()
            ax = dtl.plot_polygon(ilp,ax,col = 'b',lw = 4)
            plt.show()
        rg = pgr.planargraph()
        i1 = rg.av(p = vec3( 10,-5,0),l = 0)
        i2 = rg.av(p = vec3( 10, 5,0),l = 0)
        i3 = rg.av(p = vec3(-10, 5,0),l = 0)
        i4 = rg.av(p = vec3(-10,-5,0),l = 0)
        r1 = rg.ae(i1,i2)
        r2 = rg.ae(i2,i3)
        r3 = rg.ae(i3,i4)
        r4 = rg.ae(i4,i1)
        i5 = rg.av(p = vec3(2,-10,0),l = 0)
        r5,r6 = rg.se(i1,i4,i5)
        i6 = rg.av(p = vec3(-2,10,0),l = 0)
        r7,r8 = rg.se(i2,i3,i6)
        r9 = rg.ae(i5,i6)

        il = rg.loop(i5,i6,'cw')
        self.assertEqual(il,[i5,i6,i2,i1])
        #pl(il)
        il = rg.loop(i5,i6,'ccw')
        self.assertEqual(il,[i5,i6,i3,i4])
        #pl(il)
        il = rg.loop(i5,i1,'cw')
        self.assertEqual(il,[i5,i1,i2,i6,i3,i4])
        #pl(il)
        il = rg.loop(i5,i1,'ccw')
        self.assertEqual(il,[i5,i1,i2,i6])
        #pl(il)
        il = rg.loop(i1,i5,'cw')
        self.assertEqual(il,[i1,i5,i6,i2])
        #pl(il)

        i7,r10 = rg.mev(i1,{'p':vec3(12,-20,0),'l':0},{})

        il = rg.loop(i5,i6,'cw')
        self.assertEqual(il,[i5,i6,i2,i1])
        #pl(il)
        il = rg.loop(i5,i6,'ccw')
        self.assertEqual(il,[i5,i6,i3,i4])
        #pl(il)
        il = rg.loop(i7,i1,'cw')
        self.assertEqual(il,[i7,i1,i2,i6,i3,i4,i5,i1])
        #pl(il)
        il = rg.loop(i7,i1,'ccw')
        self.assertEqual(il,[i7,i1,i5,i4,i3,i6,i2,i1])
        #pl(il)

        i8,r11 = rg.mev(i3,{'p':vec3(-5,0,0),'l':0},{})

        il = rg.loop(i3,i4,'ccw')
        self.assertEqual(il,[i3,i4,i5,i6,i3,i8])
        #pl(il)
        il = rg.loop(i3,i4,'cw')
        self.assertEqual(il,[i3,i4,i5,i1,i7,i1,i2,i6])
        #pl(il)

        b1 = vec3(-4,0,0).pring(4,8)
        b2 = vec3(2,2,0).pring(4,8)
        b1segs = pym.bsegbxy(b1,b2)
        b2segs = pym.bsegbxy(b2,b1)
        rg = pym.sstopg(b1segs+b2segs)
        il = rg.loop(3,4,'ccw')
        #pl(il)

        il = rg.loop(1,2,'ccw')
        #pl(il)

        #il = rg.loop(1,3,'ccw')
        #pl(il)

        il = rg.loop(2,3,'ccw')
        #pl(il)

        il = rg.loop(4,5,'ccw')
        #pl(il)

        il = rg.loop(5,6,'ccw')
        #pl(il)

        il = rg.loop(6,7,'ccw')
        #pl(il)

        il = rg.loop(7,8,'ccw')