#include #include #include /** @brief Calculates cross-section of vesicle with plane. * * Function returns points of cross-section of vesicle with plane. Plane is described with equation $ax+by+cz+d=0$. Algorithm extracts coordinates of each vertex of a vesicle and then: * * if a distance of point to plane (given by equation $D=\frac{ax_0+by_0+cz_0+d}{\sqrt{a^2+b^2+c^2}}$, where $x_0$, $y_0$ and $z_0$ are coordinates of a given vertex) is less than maximal allowed distance between vertices {\tt sqrt(vesicle->dmax)} than vertex is a candidate for crossection calculation. * */ ts_coord_list *get_crossection_with_plane(ts_vesicle *vesicle,ts_double a,ts_double b,ts_double c, ts_double d){ ts_uint i, j; ts_double pp,Dsq; // distance from the plane squared ts_double ppn; // distance from the plane squared of a neighbor ts_double u; //factor to scale vector from first vector to the second to get intersection ts_vertex *vtx; ts_coord_list *pts=init_coord_list(); for(i=0;ivlist->n;i++){ vtx=vesicle->vlist->vtx[i]; pp=vtx->x*a+vtx->y*b+vtx->z*c+d; Dsq=pp*pp/(a*a+b*b+c*c); if(Dsqdmax){ for(j=0;jneigh_no;j++){ ppn=vtx->neigh[j]->x*a+vtx->neigh[j]->y*b+vtx->neigh[j]->z*c+d; if(pp*ppn<0){ //the combination of vertices are good candidates for a crossection u=pp/(a*(vtx->x-vtx->neigh[j]->x)+b*(vtx->y-vtx->neigh[j]->y)+c*(vtx->z-vtx->neigh[j]->z)); add_coord(pts, vtx->x+u*(vtx->neigh[j]->x - vtx->x), vtx->y+u*(vtx->neigh[j]->y - vtx->y), vtx->z+u*(vtx->neigh[j]->z - vtx->z), TS_COORD_CARTESIAN); } } } } return pts; }