commit | author | age
|
d7639a
|
1 |
#include<stdlib.h> |
SP |
2 |
#include "general.h" |
|
3 |
#include "cell.h" |
f74313
|
4 |
#include "frame.h" |
d7639a
|
5 |
ts_bool centermass(ts_vesicle *vesicle){ |
f74313
|
6 |
ts_uint i, n=vesicle->vlist->n; |
SP |
7 |
ts_vertex **vtx=vesicle->vlist->vtx; |
d7639a
|
8 |
vesicle->cm[0]=0; |
SP |
9 |
vesicle->cm[1]=0; |
|
10 |
vesicle->cm[2]=0; |
f74313
|
11 |
for(i=0;i<n;i++){ |
8f6a69
|
12 |
vesicle->cm[0]+=vtx[i]->x; |
SP |
13 |
vesicle->cm[1]+=vtx[i]->y; |
|
14 |
vesicle->cm[2]+=vtx[i]->z; |
d7639a
|
15 |
} |
dac2e5
|
16 |
vesicle->cm[0]/=(ts_float)n; |
SP |
17 |
vesicle->cm[1]/=(ts_float)n; |
|
18 |
vesicle->cm[2]/=(ts_float)n; |
919555
|
19 |
|
SP |
20 |
for(i=0;i<n;i++){ |
|
21 |
vtx[i]->x-=vesicle->cm[0]; |
|
22 |
vtx[i]->y-=vesicle->cm[1]; |
|
23 |
vtx[i]->z-=vesicle->cm[2]; |
|
24 |
} |
|
25 |
|
d7639a
|
26 |
return TS_SUCCESS; |
SP |
27 |
} |
|
28 |
|
f74313
|
29 |
ts_bool cell_occupation(ts_vesicle *vesicle){ |
SP |
30 |
ts_uint i,cellidx, n=vesicle->vlist->n; |
d7639a
|
31 |
ts_double shift; |
SP |
32 |
ts_double dcell; |
f74313
|
33 |
shift=(ts_double) vesicle->clist->ncmax[0]/2; |
d7639a
|
34 |
dcell=1.0/(1.0 + vesicle->stepsize); |
34d3de
|
35 |
//`fprintf(stderr, "Bil sem tu\n"); |
d7639a
|
36 |
|
f74313
|
37 |
cell_list_cell_occupation_clear(vesicle->clist); |
SP |
38 |
for(i=0;i<n;i++){ |
|
39 |
cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]); |
8f6a69
|
40 |
vesicle->vlist->vtx[i]->cell=vesicle->clist->cell[cellidx]; |
d7639a
|
41 |
|
f74313
|
42 |
cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]); |
d7639a
|
43 |
|
SP |
44 |
} |
dac2e5
|
45 |
//fprintf(stderr, "Bil sem tu\n"); |
41a035
|
46 |
if(dcell); |
SP |
47 |
if(shift); |
d7639a
|
48 |
return TS_SUCCESS; |
SP |
49 |
} |