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