bool diagonal ( tVertex a, tVertex b ) /******************************************************************************/ /* Purpose: DIAGONAL returns TRUE iff (A,B) is a proper internal diagonal of the polygon. Modified: 30 April 2007 Author: Joseph O'Rourke Parameters: Input, tVertex A, B, two vertices of the polygon. Output, bool DIAGONAL, is TRUE if the line connecting A and B is a proper internal diagonal of the polygon. */ { bool value; value = in_cone ( a, b ) && in_cone ( b, a ) && diagonalie ( a, b ); return value; }
int diagonal ( int im1, int ip1, int n, int prev[], int next[], double x[], double y[] ) /******************************************************************************/ /* Purpose: DIAGONAL: VERTEX(IM1) to VERTEX(IP1) is a proper internal diagonal. Licensing: This code is distributed under the GNU LGPL license. Modified: 05 May 2014 Author: Original C version by Joseph ORourke. This C version by John Burkardt. Reference: Joseph ORourke, Computational Geometry in C, Cambridge, 1998, ISBN: 0521649765, LC: QA448.D38. Parameters: Input, int IM1, IP1, the indices of two vertices. Input, int N, the number of vertices. Input, int PREV[N], the previous neighbor of each vertex. Input, int NEXT[N], the next neighbor of each vertex. Input, double X[N], Y[N], the coordinates of each vertex. Output, int DIAGONAL, the value of the test. */ { int value; int value1; int value2; int value3; value1 = in_cone ( im1, ip1, n, prev, next, x, y ); value2 = in_cone ( ip1, im1, n, prev, next, x, y ); value3 = diagonalie ( im1, ip1, n, next, x, y ); value = ( value1 && value2 && value3 ); return value; }
/* ptVis: * Given a vconfig_t conf, representing polygonal barriers, * and a point within one of the polygons, compute the point's * visibility vector relative to the vertices of the remaining * polygons, i.e., pretend the argument polygon is invisible. * * If pp is NIL, ptVis computes the visibility vector for p * relative to all barrier vertices. */ COORD* ptVis (vconfig_t *conf, int pp, Ppoint_t p) { int V = conf->N; Ppoint_t* pts = conf->P; int* nextPt = conf->next; int* prevPt = conf->prev; int k; int start, end; COORD* vadj; Ppoint_t pk; COORD d; vadj = (COORD*)malloc((V+2)*sizeof(COORD)); if (pp == POLYID_UNKNOWN) pp = polyhit(conf,p); if (pp >= 0) { start = conf->start[pp]; end = conf->start[pp+1]; } else { start = V; end = V; } for (k = 0; k < start; k++) { pk = pts[k]; if (in_cone (pts[prevPt[k]],pk,pts[nextPt[k]],p) && clear(p,pk,start,end,V,pts,nextPt,prevPt)) { /* if p and pk see each other, add edge */ d = dist (p, pk); vadj[k] = d; } else vadj[k] = 0; } for (k = start; k < end; k++) vadj[k] = 0; for (k = end; k < V; k++) { pk = pts[k]; if (in_cone (pts[prevPt[k]],pk,pts[nextPt[k]],p) && clear(p,pk,start,end,V,pts,nextPt,prevPt)) { /* if p and pk see each other, add edge */ d = dist (p, pk); vadj[k] = d; } else vadj[k] = 0; } vadj[V] = 0; vadj[V+1] = 0; return vadj; }
static int inCone (int i, int j, Ppoint_t pts[], int nextPt[], int prevPt[]) { return in_cone (pts[prevPt[i]],pts[i],pts[nextPt[i]],pts[j]); }