Exemple #1
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)
Exemple #2
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)
Exemple #3
0
    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()
Exemple #4
0
    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()
Exemple #5
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
Exemple #6
0
def I(sq, g):
    sq = pym.bisectb(sq)
    i1 = g.av(p=sq[0], l=0)
    i2 = g.av(p=sq[1], l=0)
    i3 = g.av(p=sq[2], l=0)
    i4 = g.av(p=sq[6], l=0)
    i5 = g.av(p=sq[5], l=0)
    i6 = g.av(p=sq[4], l=0)
    e1 = g.ae(i1, i2, **{})
    e2 = g.ae(i2, i3, **{})
    e3 = g.ae(i4, i5, **{})
    e4 = g.ae(i5, i6, **{})
    e5 = g.ae(i2, i5, **{})
Exemple #7
0
def I(sq,g):
    sq = pym.bisectb(sq)
    i1 = g.av(p = sq[0],l = 0)
    i2 = g.av(p = sq[1],l = 0)
    i3 = g.av(p = sq[2],l = 0)
    i4 = g.av(p = sq[6],l = 0)
    i5 = g.av(p = sq[5],l = 0)
    i6 = g.av(p = sq[4],l = 0)
    e1 = g.ae(i1,i2,**{})
    e2 = g.ae(i2,i3,**{})
    e3 = g.ae(i4,i5,**{})
    e4 = g.ae(i5,i6,**{})
    e5 = g.ae(i2,i5,**{})
Exemple #8
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
Exemple #9
0
    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()
Exemple #10
0
 def raise_earth(topo, tips, e, mingrad=1.0, mindelz=-5.0, depth=0):
     if depth == 0:
         for j, tip in enumerate(tips):
             tips[j].loop = pym.bisectb(tips[j].loop)
     #if depth == 10:return
     print('... raising earth ... (depth: %d)' % depth)
     newtips = []
     for tip in tips:
         if tip is None: continue
         newloop = [p.cp().ztrn(mindelz) for p in tip.loop]
         newloop = pym.aggregate(
             pym.contract(newloop, abs(mindelz / mingrad)), 5)
         #uloops = [pym.smoothxyi(newloop,0.8,e,10,1)]
         #uloops = [pym.pinchb(u,10) for u in uloops if u]
         #uloops = [pym.pinchb(newloop,10)]
         uloops = pym.pinchb(newloop, 10)
         uloops = [u for u in uloops if u]
         for u in uloops:
             if not pym.bccw(u):
                 u.reverse()
         '''
         if len(uloops) == 1:
             print('... 1 loop to raise ...')
             theloop = uloops[0]
             newtiparea = pym.bareaxy(theloop,True)
         elif uloops:
             print('... 2+ loops to raise ...')
             bareas = [pym.bareaxy(u,True) for u in uloops]
             theloop = uloops[bareas.index(max(bareas))]
             newtiparea = max(bareas)
         else:
             print('... no loops to raise ...')
             theloop = []
         '''
         for theloop in uloops:
             newtiparea = pym.bareaxy(theloop, True)
             newtip = None
             if theloop and newtiparea > 10:  #2*(e)**2:
                 newtip = topo.avert(tip, loop=theloop)
             else:
                 print('... abortive tip! ...')
             if newtip is None: continue
             else: newtips.append(newtip)
     if newtips:
         terrain.raise_earth(topo, newtips, e, mingrad, mindelz, depth + 1)
     else:
         print('... exhausted tip! ...')
Exemple #11
0
    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()
Exemple #12
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
Exemple #13
0
 def raise_earth(topo,tips,e,mingrad = 1.0,mindelz = -5.0,depth = 0):
     if depth == 0:
         for j,tip in enumerate(tips):
             tips[j].loop = pym.bisectb(tips[j].loop)
     #if depth == 10:return
     print('... raising earth ... (depth: %d)' % depth)
     newtips = []
     for tip in tips:
         if tip is None:continue
         newloop = [p.cp().ztrn(mindelz) for p in tip.loop]
         newloop = pym.aggregate(pym.contract(newloop,abs(mindelz/mingrad)),5)
         #uloops = [pym.smoothxyi(newloop,0.8,e,10,1)]
         #uloops = [pym.pinchb(u,10) for u in uloops if u]
         #uloops = [pym.pinchb(newloop,10)]
         uloops = pym.pinchb(newloop,10)
         uloops = [u for u in uloops if u]
         for u in uloops:
             if not pym.bccw(u):
                 u.reverse()
         '''
         if len(uloops) == 1:
             print('... 1 loop to raise ...')
             theloop = uloops[0]
             newtiparea = pym.bareaxy(theloop,True)
         elif uloops:
             print('... 2+ loops to raise ...')
             bareas = [pym.bareaxy(u,True) for u in uloops]
             theloop = uloops[bareas.index(max(bareas))]
             newtiparea = max(bareas)
         else:
             print('... no loops to raise ...')
             theloop = []
         '''
         for theloop in uloops:
             newtiparea = pym.bareaxy(theloop,True)
             newtip = None
             if theloop and newtiparea > 10:#2*(e)**2:
                 newtip = topo.avert(tip,loop = theloop)
             else:print('... abortive tip! ...')
             if newtip is None:continue
             else:newtips.append(newtip)
     if newtips:
         terrain.raise_earth(topo,newtips,e,mingrad,mindelz,depth+1)
     else:print('... exhausted tip! ...')
Exemple #14
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