commit | author | age
|
0af0cf
|
1 |
#include<general.h> |
SP |
2 |
#include<cross-section.h> |
|
3 |
#include<coord.h> |
|
4 |
|
|
5 |
/** @brief Calculates cross-section of vesicle with plane. |
|
6 |
* |
|
7 |
* 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: |
|
8 |
* |
|
9 |
* 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. |
|
10 |
* |
|
11 |
*/ |
|
12 |
ts_coord_list get_crossection_with_plane(ts_vesicle vesicle,ts_double a,ts_double b,ts_double c, ts_double d){ |
|
13 |
|
|
14 |
|
|
15 |
ts_uint i, j, k; |
|
16 |
ts_double pp,Dsq; // distance from the plane squared |
|
17 |
ts_double ppn,Dsqn; // distance from the plane squared of a neighbor |
|
18 |
ts_double u; //factor to scale vector from first vector to the second to get intersection |
|
19 |
ts_vertex *vtx; |
|
20 |
|
|
21 |
ts_coord_list *pts=init_coord_list(); |
|
22 |
for(i=0;i<vesicle->vlist->N;i++){ |
|
23 |
vtx=vesicle->vlist->vtx[i]; |
|
24 |
|
|
25 |
pp=vtx->x*a+vtx->y*b+vtx->z*c+d; |
|
26 |
Dsq=pp*pp/(a*a+b*b+c*c); |
|
27 |
if(Dsq<vesicle->dmax){ |
|
28 |
for(j=0;j<vtx->neigh_no;j++){ |
|
29 |
ppn=vtx->neigh[j]->x*a+vtx->neigh[j]->y*b+vtx->neigh[j]->z*c+d; |
|
30 |
if(pp*ppn<0){ //the combination of vertices are good candidates for a crossection |
|
31 |
u=pp/(a*(vtx->x-vtx->neigh[j]->x)+b*(vtx->y-vtx->neigh[j]->y)+c(vtx->z-vtx->neigh[j]->z)); |
|
32 |
add_coord(pts, vtx->x+u(vtx->neigh[j]->x - vtx->x), |
|
33 |
vtx->y+u(vtx->neigh[j]->y - vtx->y), |
|
34 |
vtx->z+u(vtx->neigh[j]->z - vtx->z), |
|
35 |
TS_COORD_CARTESIAN); |
|
36 |
} |
|
37 |
} |
|
38 |
} |
|
39 |
} |
|
40 |
return pts; |
|
41 |
} |
|
42 |
|
|
43 |
|