コード例 #1
0
ファイル: terrain.py プロジェクト: ctogle/dilapidator
 def sow_earth(b,e):
     '''generate landmasses within a boundary polygon'''
     lm = pym.contract(b,e*50.0,e)
     return [lm]
     for x in range(10):lm = pyg.ajagged(lm,e)
     lm = pym.bisectb(lm)
     lm = pym.smoothxy(lm,0.5,e)
     lm = pym.smoothxy(lm,0.5,e)
     lm = pym.smoothxy(lm,0.5,e)
     lm = pym.aggregate(lm,2)
     lm = pym.blimithmin(lm,2,50)
     lms = [lm]
     return lms
コード例 #2
0
 def sow_earth(b, e):
     '''generate landmasses within a boundary polygon'''
     lm = pym.contract(b, e * 50.0, e)
     return [lm]
     for x in range(10):
         lm = pyg.ajagged(lm, e)
     lm = pym.bisectb(lm)
     lm = pym.smoothxy(lm, 0.5, e)
     lm = pym.smoothxy(lm, 0.5, e)
     lm = pym.smoothxy(lm, 0.5, e)
     lm = pym.aggregate(lm, 2)
     lm = pym.blimithmin(lm, 2, 50)
     lms = [lm]
     return lms
コード例 #3
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()
コード例 #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
ファイル: polymath_tests.py プロジェクト: ctogle/dilapidator
    def atest_contract(self):
        def pl(b):
            ax = dtl.plot_axes_xy(300)
            ax = dtl.plot_polygon_xy(b,ax)
            plt.show()

        b = pym.ebuxy(vec3(0,100,0).sq(500,200),vec3(100,0,0).sq(200,500))[0]
        b = pym.bisectb(b)
        b = pym.bisectb(b)
        b = pym.smoothxy(b,0.2)
        b = pym.contract(b,25)
コード例 #6
0
    def atest_contract(self):
        def pl(b):
            ax = dtl.plot_axes_xy(300)
            ax = dtl.plot_polygon_xy(b, ax)
            plt.show()

        b = pym.ebuxy(
            vec3(0, 100, 0).sq(500, 200),
            vec3(100, 0, 0).sq(200, 500))[0]
        b = pym.bisectb(b)
        b = pym.bisectb(b)
        b = pym.smoothxy(b, 0.2)
        b = pym.contract(b, 25)
コード例 #7
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
コード例 #8
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()
コード例 #9
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
コード例 #10
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()
コード例 #11
0
def pepper(t, tip, e=2):
    print('pepper')

    c = vec3(0, 0, 0).com(tip.loop)
    d = vec3(1, 0, 0).uscl(1000)
    s1, s2 = c.cp().trn(d.flp()), c.cp().trn(d.flp())
    ch = lambda b: pyg.chunk(
        b, e, random.random() + 0.2, edge=random.randint(0, 1))
    bs = [ch(tip.loop) for x in range(10)]
    bs = pym.bsuxy(bs, e)

    #ax = dtl.plot_axes_xy(200)
    #for b in bs:
    #    dtl.plot_polygon_xy(b,ax,lw = 2)
    #plt.show()

    newtips = []
    for sb in bs:
        if not pym.bccw(sb): sb.reverse()

        sb = pyg.ajagged(sb, 2)
        sb = pyg.ajagged(sb, 2)
        sb = pyg.ajagged(sb, 2)
        #sb = pyg.ajagged(sb,2)

        #for x in range(3):b = pyg.ajagged(b,e)
        sb = pym.bisectb(sb)
        #sb = pym.smoothxy(sb,0.5,e)
        sb = pym.smoothxy(sb, 0.5, e)
        sb = pym.aggregate(sb, 4)
        #sb = pym.blimithmin(sb,2,50)

        for p in sb:
            p.ztrn(2)
        newtips.append(t.al(sb, tip))

    ax = dtl.plot_axes(200)
    ax = dtl.plot_polygon(t.root.loop, ax, ls='--', lw=2, col='k')
    ax = dtl.plot_polygon(tip.loop, ax, lw=3, col='r')
    for b in bs:
        ax = dtl.plot_polygon(b, ax, lw=3, col='g')
    plt.show()

    return newtips
コード例 #12
0
ファイル: terrain.py プロジェクト: ctogle/dilapidator
def pepper(t,tip,e = 2):
    print('pepper')

    c = vec3(0,0,0).com(tip.loop)
    d = vec3(1,0,0).uscl(1000)
    s1,s2 = c.cp().trn(d.flp()),c.cp().trn(d.flp())
    ch = lambda b : pyg.chunk(b,e,random.random()+0.2,edge = random.randint(0,1))
    bs = [ch(tip.loop) for x in range(10)]
    bs = pym.bsuxy(bs,e)

    #ax = dtl.plot_axes_xy(200)
    #for b in bs:
    #    dtl.plot_polygon_xy(b,ax,lw = 2)
    #plt.show()

    newtips = []
    for sb in bs:
        if not pym.bccw(sb):sb.reverse()

        sb = pyg.ajagged(sb,2)
        sb = pyg.ajagged(sb,2)
        sb = pyg.ajagged(sb,2)
        #sb = pyg.ajagged(sb,2)

        #for x in range(3):b = pyg.ajagged(b,e)
        sb = pym.bisectb(sb)
        #sb = pym.smoothxy(sb,0.5,e)
        sb = pym.smoothxy(sb,0.5,e)
        sb = pym.aggregate(sb,4)
        #sb = pym.blimithmin(sb,2,50)

        for p in sb:p.ztrn(2)
        newtips.append(t.al(sb,tip))

    ax = dtl.plot_axes(200)
    ax = dtl.plot_polygon(t.root.loop,ax,ls = '--',lw = 2,col = 'k')
    ax = dtl.plot_polygon(tip.loop,ax,lw = 3,col = 'r')
    for b in bs:
        ax = dtl.plot_polygon(b,ax,lw = 3,col = 'g')
    plt.show()

    return newtips
コード例 #13
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
コード例 #14
0
ファイル: partitiongraph.py プロジェクト: ctogle/dilapidator
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
コード例 #15
0
ファイル: partitiongraph.py プロジェクト: ctogle/dilapidator
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
コード例 #16
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