commit | author | age
|
d7639a
|
1 |
#include<stdlib.h> |
SP |
2 |
#include "general.h" |
|
3 |
#include "cell.h" |
f74313
|
4 |
#include "frame.h" |
ea1cce
|
5 |
|
d7639a
|
6 |
ts_bool centermass(ts_vesicle *vesicle){ |
3a018d
|
7 |
ts_uint i,j, n=vesicle->vlist->n; |
f74313
|
8 |
ts_vertex **vtx=vesicle->vlist->vtx; |
d7639a
|
9 |
vesicle->cm[0]=0; |
SP |
10 |
vesicle->cm[1]=0; |
|
11 |
vesicle->cm[2]=0; |
f74313
|
12 |
for(i=0;i<n;i++){ |
8f6a69
|
13 |
vesicle->cm[0]+=vtx[i]->x; |
SP |
14 |
vesicle->cm[1]+=vtx[i]->y; |
|
15 |
vesicle->cm[2]+=vtx[i]->z; |
d7639a
|
16 |
} |
dac2e5
|
17 |
vesicle->cm[0]/=(ts_float)n; |
SP |
18 |
vesicle->cm[1]/=(ts_float)n; |
|
19 |
vesicle->cm[2]/=(ts_float)n; |
919555
|
20 |
|
SP |
21 |
for(i=0;i<n;i++){ |
|
22 |
vtx[i]->x-=vesicle->cm[0]; |
|
23 |
vtx[i]->y-=vesicle->cm[1]; |
|
24 |
vtx[i]->z-=vesicle->cm[2]; |
|
25 |
} |
58230a
|
26 |
//move polymers for the same vector as we moved vesicle |
3a018d
|
27 |
for(i=0;i<vesicle->poly_list->n;i++){ |
M |
28 |
for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ |
|
29 |
vesicle->poly_list->poly[i]->vlist->vtx[j]->x-=vesicle->cm[0]; |
|
30 |
vesicle->poly_list->poly[i]->vlist->vtx[j]->y-=vesicle->cm[1]; |
|
31 |
vesicle->poly_list->poly[i]->vlist->vtx[j]->z-=vesicle->cm[2]; |
|
32 |
} |
|
33 |
} |
58230a
|
34 |
//move filaments for the same vector as we moved vesicle |
M |
35 |
for(i=0;i<vesicle->filament_list->n;i++){ |
|
36 |
for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ |
|
37 |
vesicle->filament_list->poly[i]->vlist->vtx[j]->x-=vesicle->cm[0]; |
|
38 |
vesicle->filament_list->poly[i]->vlist->vtx[j]->y-=vesicle->cm[1]; |
|
39 |
vesicle->filament_list->poly[i]->vlist->vtx[j]->z-=vesicle->cm[2]; |
|
40 |
} |
|
41 |
} |
3a018d
|
42 |
|
58230a
|
43 |
vesicle->cm[0]=0.0; |
M |
44 |
vesicle->cm[1]=0.0; |
|
45 |
vesicle->cm[2]=0.0; |
a63f17
|
46 |
|
d7639a
|
47 |
return TS_SUCCESS; |
SP |
48 |
} |
|
49 |
|
f74313
|
50 |
ts_bool cell_occupation(ts_vesicle *vesicle){ |
48bb92
|
51 |
ts_uint i,j,cellidx, n=vesicle->vlist->n; |
d7639a
|
52 |
|
f74313
|
53 |
cell_list_cell_occupation_clear(vesicle->clist); |
SP |
54 |
for(i=0;i<n;i++){ |
|
55 |
cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]); |
a63f17
|
56 |
// already done in cell_add_vertex |
SP |
57 |
// vesicle->vlist->vtx[i]->cell=vesicle->clist->cell[cellidx]; |
d7639a
|
58 |
|
f74313
|
59 |
cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]); |
d7639a
|
60 |
} |
48bb92
|
61 |
|
58230a
|
62 |
//Add all polymers to cells |
48bb92
|
63 |
for(i=0;i<vesicle->poly_list->n;i++){ |
M |
64 |
for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ |
|
65 |
cellidx=vertex_self_avoidance(vesicle, vesicle->poly_list->poly[i]->vlist->vtx[j]); |
|
66 |
cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->poly_list->poly[i]->vlist->vtx[j]); |
|
67 |
} |
|
68 |
} |
58230a
|
69 |
//Add all filaments to cells |
M |
70 |
for(i=0;i<vesicle->filament_list->n;i++){ |
|
71 |
for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ |
|
72 |
cellidx=vertex_self_avoidance(vesicle, vesicle->filament_list->poly[i]->vlist->vtx[j]); |
|
73 |
cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->filament_list->poly[i]->vlist->vtx[j]); |
|
74 |
} |
|
75 |
} |
|
76 |
|
48bb92
|
77 |
|
d7639a
|
78 |
return TS_SUCCESS; |
SP |
79 |
} |