| 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; |
| 0dd5ba | 12 | ts_double temp_z_cm=0; |
| d7639a | 13 | vesicle->cm[0]=0; |
| SP | 14 | vesicle->cm[1]=0; |
| 15 | vesicle->cm[2]=0; | |
| f74313 | 16 | for(i=0;i<n;i++){ |
| 8f6a69 | 17 | vesicle->cm[0]+=vtx[i]->x; |
| SP | 18 | vesicle->cm[1]+=vtx[i]->y; |
| 19 | vesicle->cm[2]+=vtx[i]->z; | |
| d7639a | 20 | } |
| dac2e5 | 21 | vesicle->cm[0]/=(ts_float)n; |
| SP | 22 | vesicle->cm[1]/=(ts_float)n; |
| 23 | vesicle->cm[2]/=(ts_float)n; | |
| 0dd5ba | 24 | |
| SP | 25 | //center mass for z component does not change if we confine the vesicle with plates |
| 26 | if(vesicle->tape->plane_confinement_switch){ | |
| 27 | temp_z_cm=vesicle->cm[2]; | |
| 28 | vesicle->cm[2]=0; | |
| 29 | } | |
| 919555 | 30 | |
| SP | 31 | for(i=0;i<n;i++){ |
| 32 | vtx[i]->x-=vesicle->cm[0]; | |
| 33 | vtx[i]->y-=vesicle->cm[1]; | |
| 34 | vtx[i]->z-=vesicle->cm[2]; | |
| 35 | } | |
| 58230a | 36 | //move polymers for the same vector as we moved vesicle |
| 3a018d | 37 | for(i=0;i<vesicle->poly_list->n;i++){ |
| M | 38 | for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ |
| 39 | vesicle->poly_list->poly[i]->vlist->vtx[j]->x-=vesicle->cm[0]; | |
| 40 | vesicle->poly_list->poly[i]->vlist->vtx[j]->y-=vesicle->cm[1]; | |
| 41 | vesicle->poly_list->poly[i]->vlist->vtx[j]->z-=vesicle->cm[2]; | |
| 42 | } | |
| 43 | } | |
| 58230a | 44 | //move filaments for the same vector as we moved vesicle |
| M | 45 | for(i=0;i<vesicle->filament_list->n;i++){ |
| 46 | for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ | |
| 47 | vesicle->filament_list->poly[i]->vlist->vtx[j]->x-=vesicle->cm[0]; | |
| 48 | vesicle->filament_list->poly[i]->vlist->vtx[j]->y-=vesicle->cm[1]; | |
| 49 | vesicle->filament_list->poly[i]->vlist->vtx[j]->z-=vesicle->cm[2]; | |
| 50 | } | |
| 51 | } | |
| 4891eb | 52 | //move nucleus for the same vector as we moved vesicle |
| SP | 53 | vesicle->nucleus_center[0]-=vesicle->cm[0]; |
| 54 | vesicle->nucleus_center[1]-=vesicle->cm[1]; | |
| 55 | vesicle->nucleus_center[2]-=vesicle->cm[2]; | |
| 3a018d | 56 | |
| 58230a | 57 | vesicle->cm[0]=0.0; |
| M | 58 | vesicle->cm[1]=0.0; |
| 0dd5ba | 59 | if(vesicle->tape->plane_confinement_switch){ |
| SP | 60 | vesicle->cm[2]=temp_z_cm; |
| 61 | } | |
| a63f17 | 62 | |
| 3de289 | 63 | for(i=0;i<vesicle->tlist->n;i++){ |
| SP | 64 | triangle_normal_vector(vesicle->tlist->tria[i]); |
| 65 | } | |
| 66 | ||
| 67 | ||
| d7639a | 68 | return TS_SUCCESS; |
| SP | 69 | } |
| 70 | ||
| f74313 | 71 | ts_bool cell_occupation(ts_vesicle *vesicle){ |
| 48bb92 | 72 | ts_uint i,j,cellidx, n=vesicle->vlist->n; |
| d7639a | 73 | |
| f74313 | 74 | cell_list_cell_occupation_clear(vesicle->clist); |
| SP | 75 | for(i=0;i<n;i++){ |
| 76 | cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]); | |
| a63f17 | 77 | // already done in cell_add_vertex |
| SP | 78 | // vesicle->vlist->vtx[i]->cell=vesicle->clist->cell[cellidx]; |
| d7639a | 79 | |
| f74313 | 80 | cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]); |
| d7639a | 81 | } |
| 48bb92 | 82 | |
| 58230a | 83 | //Add all polymers to cells |
| 90882f | 84 | if(vesicle->poly_list!=NULL){ |
| 48bb92 | 85 | for(i=0;i<vesicle->poly_list->n;i++){ |
| M | 86 | for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ |
| 87 | cellidx=vertex_self_avoidance(vesicle, vesicle->poly_list->poly[i]->vlist->vtx[j]); | |
| 88 | cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->poly_list->poly[i]->vlist->vtx[j]); | |
| 89 | } | |
| 90 | } | |
| 90882f | 91 | } |
| 58230a | 92 | //Add all filaments to cells |
| 90882f | 93 | if(vesicle->filament_list!=NULL){ |
| 58230a | 94 | for(i=0;i<vesicle->filament_list->n;i++){ |
| M | 95 | for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ |
| 96 | cellidx=vertex_self_avoidance(vesicle, vesicle->filament_list->poly[i]->vlist->vtx[j]); | |
| 97 | cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->filament_list->poly[i]->vlist->vtx[j]); | |
| 98 | } | |
| 99 | } | |
| 90882f | 100 | } |
| 48bb92 | 101 | |
| d7639a | 102 | return TS_SUCCESS; |
| SP | 103 | } |