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
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
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
def length( a ): #return math.sqrt( numpy.dot( a, a ) ) return _gfrd.distance( ZEROPOS, a )
def randomVector( r ): v = numpy.random.uniform( -1, 1, 3 ) return v * ( r / _gfrd.distance( ZEROPOS, v ) )
def randomUnitVector(): v = numpy.random.uniform( -1, 1, 3 ) return v / _gfrd.distance( ZEROPOS, v )
def distance_Simple( position1, position2, fsize = 0 ): return _gfrd.distance( position1, position2 )