double* acidvector(atom a, atom b){ /*acid [0] [1] [2] [3]*/ double* avector = malloc(sizeof(double)*3); //there are 3 vectors in one acid avector[0] = pointdistance(a.x, b.x); avector[1] = pointdistance(a.y, b.y); avector[2] = pointdistance(a.z, b.z); //fprintf(stderr, "ohhhhhhhhhhhhhhhhhh: %lf \n%lf\n%lf\n\n\n", avector[0], avector[1], avector[2]); return avector; }
bool spheresphere(coordinate& c1,float r1,coordinate c2,float r2) { float dist=pointdistance(c1,c2); if(dist<=(r1+r2)*(r1+r2)) { float a=sqrt(dist)-(r1+r2); coordinate vec(c2.x-c1.x,c2.y-c1.y,c2.z-c1.z); //c2-c1 float len=sqrt((vec.x*vec.x+vec.y*vec.y+vec.z*vec.z)); vec.x/=len; vec.y/=len; vec.z/=len; c1.x=c1.x+vec.x*a; c1.y=c1.y+vec.y*a; c1.z=c1.z+vec.z*a; return 1; } return 0; }
bool Functions:: spheresphere(vector3d& c1,float r1,vector3d c2,float r2) { float dist=pointdistance(c1,c2); if(dist<=(r1+r2)*(r1+r2)) { float a=sqrt(dist)-(r1+r2); vector3d vec(c2.x-c1.x,c2.y-c1.y,c2.z-c1.z); //c2-c1 float len=sqrt((vec.x*vec.x+vec.y*vec.y+vec.z*vec.z)); vec.x/=len; vec.y/=len; vec.z/=len; c1.x=c1.x+vec.x*a; c1.y=c1.y+vec.y*a; c1.z=c1.z+vec.z*a; return 1; } return 0; }