Lastly before debugging. We calculated the area of each triangle, volume function has been changed and data structure adapted for area calculation
| | |
| | | ts_double ynorm; |
| | | ts_double znorm; |
| | | ts_double area; // firstly needed for sh.c |
| | | ts_double volume; // firstly needed for sh.c |
| | | }; |
| | | typedef struct ts_triangle ts_triangle; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /*Computes Y(l,m,theta,fi) (Miha's definition that is different from common definition for factor srqt(1/(2*pi)) */ |
| | | /** @brief: Computes Y(l,m,theta,fi) |
| | | * |
| | | * Function calculates Y^l_m for vertex with given (\theta, \fi) coordinates in |
| | | * spherical coordinate system. |
| | | * @param l is an ts_int argument. |
| | | * @param m is an ts_int argument. |
| | | * @param theta is ts_double argument. |
| | | * @param fi is a ts_double argument. |
| | | * |
| | | * (Miha's definition that is different from common definition for factor srqt(1/(2*pi)) */ |
| | | ts_double shY(ts_int l,ts_int m,ts_double theta,ts_double fi){ |
| | | ts_double fac1, fac2, K; |
| | | int i; |
| | |
| | | tria->xnorm=tria->xnorm/xden; |
| | | tria->ynorm=tria->ynorm/xden; |
| | | tria->znorm=tria->znorm/xden; |
| | | |
| | | /* Here it is an excellent point to recalculate volume of the triangle and |
| | | * store it into datastructure. Volume is required at least by constant volume |
| | | * calculation of vertex move and bondflip and spherical harmonics. */ |
| | | tria->volume=(tria->vertex[0]->x+ tria->vertex[1]->x + tria->vertex[2]->x) * tria->xnorm + |
| | | (tria->vertex[0]->y+ tria->vertex[1]->y + tria->vertex[2]->y) * tria->ynorm + |
| | | (tria->vertex[0]->z+ tria->vertex[1]->z + tria->vertex[2]->z) * tria->znorm; |
| | | tria->volume=-xden*tria->volume/18.0; |
| | | /* Also, area can be calculated in each triangle */ |
| | | tria->area=xden/2; |
| | | |
| | | |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | | /* @brief Function makes a sum of partial volumes of each triangle. Volumes of |
| | | * |
| | | * Partial volumes are calculated when we calculate normals of triangles. It is |
| | | * relatively easy to calculate the volume of vesicle if we take into account |
| | | * that the volume of the whole vertex is simply sum of all partial volumes of |
| | | * all the triangles. |
| | | */ |
| | | ts_bool vesicle_volume(ts_vesicle *vesicle){ |
| | | ts_double volume; |
| | | ts_double vol; |
| | | ts_uint i; |
| | | ts_triangle **tria=vesicle->tlist->tria; |
| | | volume=0; |
| | | for(i=0; i<vesicle->tlist->n;i++){ |
| | | vol=(tria[i]->vertex[0]->x+ tria[i]->vertex[1]->x + tria[i]->vertex[2]->x) * tria[i]->xnorm + |
| | | (tria[i]->vertex[0]->y+ tria[i]->vertex[1]->y + tria[i]->vertex[2]->y) * tria[i]->ynorm + |
| | | (tria[i]->vertex[0]->z+ tria[i]->vertex[1]->z + tria[i]->vertex[2]->z) * |
| | | tria[i]->znorm; |
| | | volume=volume-vol/18.0; |
| | | volume=volume+tria[i]->volume; |
| | | } |
| | | |
| | | vesicle->volume=volume; |
| | | return TS_SUCCESS; |
| | | } |