예제 #1
0
    def entry(self):
        l, w = self.bldg.l, self.bldg.w
        subl = dpr.clamp(rm.choice([0.25 * l, 0.5 * l, 0.75 * l]), 20, l)
        subw = dpr.clamp(rm.choice([0.25 * w, 0.5 * w, 0.75 * w]), 24, w)
        mx = 0.0
        my = -w / 2.0 + subw / 2.0 + 10.0
        margs = ((), {
            'x': mx,
            'y': my,
            'l': subl,
            'w': subw,
            'shafted': False
        })
        self.create_bbox(margs)
        splan = self.should_shaft([[], [], [], []], margs)
        cpairs = self.wall_verts(margs)
        ewargs = [[
            cp, {
                'h': 4.0,
                'w': 0.5,
                'walltype': 'exterior',
                'room': margs
            }
        ] for cp in cpairs]
        ewargs[0][1]['walltype'] = 'entryway'

        rmplans = [margs]
        ewplans = ewargs[:]
        iwplans = []
        shplans = [splan] if splan else []
        return rmplans, ewplans, iwplans, shplans
예제 #2
0
def nudge(angles,ws,target = 90,error = 1):
    def acceptable(das):return abs(min(das)-target) < error
    def measure(angles):
        das = []
        dxs = []
        for x in range(acnt):
            xda,xdx = min_adist(angles[x],angles,x)
            das.append(xda)
            dxs.append(xdx)
        return das,dxs

    oas = angles[:]
    acnt = len(angles)
    if acnt == 1:return oas
    das,dxs = measure(oas)
    tries = 0
    maxtries = 100
    while not acceptable(das) and tries < maxtries:
        tries += 1
        das,dxs = measure(oas)
        tdas = [dpr.clamp(target-da,0,target) for da in das]
        es = [tda*w*0.5 for tda,w in zip(tdas,ws)]
        oas = [apply_err(oas[x],es[x],oas[dxs[x]]) for x in range(acnt)]
    if tries == maxtries:print('tries exceeded while nuding!')
    return oas
예제 #3
0
파일: tmesh.py 프로젝트: ctogle/dilapidator
 def smooth_radial(self,selfdex):
     if not self.vring:return dpv.zero()
     ns = [self.mesh.vs[x].p for x in self.vring]
     ds = [dpv.distance(n,self.p) for n in ns]
     ws = [dpr.clamp(d/max(ds),0.5,1.0) for d in ds]
     ncom = dpv.center_of_mass_weighted(ns,ws)
     return dpv.v1_v2(self.p,ncom).scale(self.w)
예제 #4
0
파일: wall.py 프로젝트: ctogle/dilapidator
    def _door_gap(self,dx,fh):
        wh,ch = self.h,fh
        dw,dh,dz = 1.5,dpr.clamp(0.8*(wh-fh-ch),2,3),fh
        dpts = self._gap(dx,dw)
        if dpts is None:return

        dargs = ((),{'z':dz,'w':dw,'h':dh,'gap':dpts,'wall':self})
        dpos = dpv.midpoint(*dpts)
        newdoor = pd.door(*dargs[0],**dargs[1]).translate(dpos)
        self.portals.append(newdoor)
예제 #5
0
    def entry(self):
        l,w = self.bldg.l,self.bldg.w
        subl = dpr.clamp(rm.choice([0.25*l,0.5*l,0.75*l]),20,l)
        subw = dpr.clamp(rm.choice([0.25*w,0.5*w,0.75*w]),24,w)
        mx = 0.0
        my = - w/2.0 + subw/2.0 + 10.0
        margs = ((),{'x':mx,'y':my,'l':subl,'w':subw,'shafted':False})
        self.create_bbox(margs)
        splan = self.should_shaft([[],[],[],[]],margs)
        cpairs = self.wall_verts(margs)
        ewargs = [[cp,
            {'h':4.0,'w':0.5,'walltype':'exterior','room':margs}] 
                for cp in cpairs]
        ewargs[0][1]['walltype'] = 'entryway'

        rmplans = [margs]
        ewplans = ewargs[:]
        iwplans = []
        shplans = [splan] if splan else []
        return rmplans,ewplans,iwplans,shplans
예제 #6
0
 def randrot(self,p,d):
     if random.random() < 0.5:newangle = 0.5*self.angle
     else:newangle = 2.0*self.angle
     self.angle = dpr.clamp(newangle,self.minangle,self.maxangle)
예제 #7
0
 def rho_down(self,p,d):self.rho = dpr.clamp(0.5*self.rho,self.minrho,self.maxrho) 
 def polar_up(self,p,d):