Esempio n. 1
0
 def check_overlap(self, sphere, ignores):
     retval = []
     for pp in self.particles.iteritems():
         if pp[0] in ignores:
             continue
         dist = _gfrd.distance(pp[1].position, sphere.position) - pp[1].radius
         if dist < sphere.radius:
             retval.append((pp, dist))
     retval.sort(lambda a, b: cmp(a[1], b[1]))
     return retval
Esempio n. 2
0
 def check_overlap(self, sphere, ignores):
     retval = []
     for pp in self.particles.iteritems():
         if pp[0] in ignores:
             continue
         dist = _gfrd.distance(pp[1].position,
                               sphere.position) - pp[1].radius
         if dist < sphere.radius:
             retval.append((pp, dist))
     retval.sort(lambda a, b: cmp(a[1], b[1]))
     return retval
Esempio n. 3
0
    def check_overlap(self, sphere, *arg):
        if len(arg) == 0:
            ignores = ()
        elif len(arg) == 1:
            if isinstance(arg[0], _gfrd.ParticleID):
                ignores = (arg[0],)
            else:
                ignores = arg[0]
        elif len(arg) == 2:
            assert all(isinstance(a, _gfrd.ParticleID) for a in arg)
            ignores = arg

        retval = []
        for pp in self.particles.iteritems():
            if pp[0] in ignores:
                continue
            dist = _gfrd.distance(pp[1].position, sphere[0]) - pp[1].radius
            if dist < sphere[1]:
                retval.append((pp, dist))
        retval.sort(lambda a, b: cmp(a[1], b[1]))
        return retval
Esempio n. 4
0
    def check_overlap(self, sphere, *arg):
        if len(arg) == 0:
            ignores = ()
        elif len(arg) == 1:
            if isinstance(arg[0], _gfrd.ParticleID):
                ignores = (arg[0], )
            else:
                ignores = arg[0]
        elif len(arg) == 2:
            assert all(isinstance(a, _gfrd.ParticleID) for a in arg)
            ignores = arg

        retval = []
        for pp in self.particles.iteritems():
            if pp[0] in ignores:
                continue
            dist = _gfrd.distance(pp[1].position, sphere[0]) - pp[1].radius
            if dist < sphere[1]:
                retval.append((pp, dist))
        retval.sort(lambda a, b: cmp(a[1], b[1]))
        return retval
Esempio n. 5
0
File: utils.py Progetto: gfrd/gfrd
def length( a ):
    #return math.sqrt( numpy.dot( a, a ) )
    return _gfrd.distance( ZEROPOS, a )
Esempio n. 6
0
File: utils.py Progetto: gfrd/gfrd
def randomVector( r ):
    v = numpy.random.uniform( -1, 1, 3 )
    return v * ( r / _gfrd.distance( ZEROPOS, v ) )
Esempio n. 7
0
File: utils.py Progetto: gfrd/gfrd
def randomUnitVector():
    v = numpy.random.uniform( -1, 1, 3 )
    return v / _gfrd.distance( ZEROPOS, v )
Esempio n. 8
0
File: utils.py Progetto: gfrd/gfrd
def distance_Simple( position1, position2, fsize = 0 ):
    return _gfrd.distance( position1, position2 )