コード例 #1
0
ファイル: aslam.py プロジェクト: athityakumar/software
 def centroid(s, t):
     pmap = s._pmap(t)
     centx, centy = 0., 0.
     for x in range(PMAP_GRID_DIM):
         for y in range(PMAP_GRID_DIM):
             centx += pmap[x][y] * x
             centy += pmap[x][y] * y
     centx *= PMAP_GRID_SCALE
     centy *= PMAP_GRID_SCALE
     return (centx, centy)
コード例 #2
0
 def centroid(s, t):
     pmap = s._pmap(t)
     centx, centy = 0., 0.
     for x in range(PMAP_GRID_DIM):
         for y in range(PMAP_GRID_DIM):
             centx += pmap[x][y] * x
             centy += pmap[x][y] * y
     centx *= PMAP_GRID_SCALE
     centy *= PMAP_GRID_SCALE
     return (centx, centy)
コード例 #3
0
ファイル: aslam.py プロジェクト: athityakumar/software
    def centroiderr(s, t):
        pmap = s._pmap(t)
        centx, centy = 0., 0.
        for x in range(PMAP_GRID_DIM):
            for y in range(PMAP_GRID_DIM):
                centx += pmap[x][y] * x
                centy += pmap[x][y] * y
        centx *= PMAP_GRID_SCALE
        centy *= PMAP_GRID_SCALE 
        spts = sorted([(x, y, mag((centx - x, centy - y))) for x in range(PMAP_GRID_DIM) for y in range(PMAP_GRID_DIM)], key=lambda t:t[2])
        psum = 0.
        i = -1
        while psum < SIGMA:
            i += 1
            psum += pmap[spts[i][0]][spts[i][1]]

        return ((centx, centy), spts[i][2])
コード例 #4
0
    def centroiderr(s, t):
        pmap = s._pmap(t)
        centx, centy = 0., 0.
        for x in range(PMAP_GRID_DIM):
            for y in range(PMAP_GRID_DIM):
                centx += pmap[x][y] * x
                centy += pmap[x][y] * y
        centx *= PMAP_GRID_SCALE
        centy *= PMAP_GRID_SCALE
        spts = sorted([(x, y, mag((centx - x, centy - y)))
                       for x in range(PMAP_GRID_DIM)
                       for y in range(PMAP_GRID_DIM)],
                      key=lambda t: t[2])
        psum = 0.
        i = -1
        while psum < SIGMA:
            i += 1
            psum += pmap[spts[i][0]][spts[i][1]]

        return ((centx, centy), spts[i][2])