Пример #1
0
def gennewcoord(pbc):
    #generate random vector on 1 sphere
    orient = usefulmath.vec_random()
    orient = usefulmath.vec_normalize(orient)

    #generate position
    pos = [random.random()*float(pbc[0]),random.random()*float(pbc[1]),random.random()*float(pbc[2])]
    
    #generate patch (perpendicular to orientation of cylinder)
    patch = usefulmath.perp_vec(orient)
    patch = usefulmath.vec_normalize(patch)
    
    #return [pos,orient]
    return [pos,orient,patch]
Пример #2
0
def gennewcoord(pbc,dist):
    #generate random vector on 1 sphere
    orient=usefulmath.vec_random()
    orient=usefulmath.vec_normalize(orient)

    dist=float(dist);
    dist2=2.0*dist;

    #generate position
    pos=[dist+random.random()*(float(pbc[0])-dist2),dist+random.random()*(float(pbc[1])-dist2),dist+random.random()*(float(pbc[2])-dist2)]
    
    #generate patch (perpendicular to orientation of cylinder)
    patch=usefulmath.perp_vec(orient)
    patch=usefulmath.vec_normalize(patch)
    
    #return [pos,orient]
    return [pos,orient,patch]