| | |
| | | #include "bond.h" |
| | | #include<stdio.h> |
| | | |
| | | ts_bool vertex_list_assign_id(ts_vertex_list *vlist, ts_uint id){ |
| | | ts_uint i; |
| | | for(i=0;i<vlist->n;i++){ |
| | | vlist->vtx[i]->id = id; |
| | | } |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | | ts_vertex_list *init_vertex_list(ts_uint N){ |
| | | ts_int i; |
| | | ts_vertex_list *vlist=(ts_vertex_list *)malloc(sizeof(ts_vertex_list)); |
| | |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | | /** Calculates the triple product of vectors defined by vertices vtx1, vtx2 and vtx3, ($\mathrm{vtx}_1\cdot(\mathrm{vtx}_2\cross\mathrm{vtx}_3$): |
| | | * \begin{vmatrix} |
| | | * x_1 & y_1 & z_1 \\ |
| | | * x_2-x_1 & y_2-y_1 & z_2-z_1\\ |
| | | * x_3-x_1 & y_3-y_1 & z_3-z_1\\ |
| | | * \end{vmatrix} |
| | | * where the vertices coordinates are denoted by corresponding vertex index number. Function is used to determine the orientation of area formed by triangle formed by the three given vertices. |
| | | * |
| | | * @param vtx1 is first vertex, according to which the orientation is calculated |
| | | * @param vtx2 is the second vertex |
| | | * @param vtx3 is the third vertex |
| | | * @returns directionality of the area of the triangle formed by vertices vtx1, vtx2 and vtx3. It is positive if vtx1, vtx2 and vtx3 are oriented counter-clockwise. |
| | | */ |
| | | inline ts_double vtx_direct(ts_vertex *vtx1, ts_vertex *vtx2, ts_vertex *vtx3){ |
| | | ts_double dX2=vtx2->x-vtx1->x; |
| | | ts_double dY2=vtx2->y-vtx1->y; |
| | |
| | | } |
| | | |
| | | return vlist; |
| | | } |
| | | |
| | | |
| | | |
| | | ts_bool vertex_taint(ts_vertex *vtx, ts_uint level){ |
| | | if(level==0){ |
| | | vtx->locked++; |
| | | return TS_SUCCESS; |
| | | } |
| | | ts_uint i; |
| | | for(i=0; i<vtx->neigh_no; i++){ |
| | | vertex_taint(vtx->neigh[i], level-1); |
| | | } |
| | | vtx->locked++; |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | | ts_bool vertex_untaint(ts_vertex *vtx, ts_uint level){ |
| | | if(level==0){ |
| | | vtx->locked--; |
| | | return TS_SUCCESS; |
| | | } |
| | | ts_uint i; |
| | | for(i=0; i<vtx->neigh_no; i++){ |
| | | vertex_untaint(vtx->neigh[i], level-1); |
| | | } |
| | | vtx->locked--; |
| | | return TS_SUCCESS; |
| | | } |
| | | |
| | | inline ts_bool vertex_tainted(ts_vertex *vtx, ts_uint level, ts_uint amount){ |
| | | if(vtx->locked>amount) return 1; |
| | | else return 0; |
| | | } |