MCPcopy Create free account
hub / github.com/apache/httpd / pointinpoly

Function pointinpoly

modules/mappers/mod_imagemap.c:174–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172#define fmax(a,b) (((a)>(b))?(a):(b))
173
174static int pointinpoly(const double point[2], double pgon[MAXVERTS][2])
175{
176 int i, numverts, crossings = 0;
177 double x = point[X], y = point[Y];
178
179 for (numverts = 0; numverts < MAXVERTS && pgon[numverts][X] != -1;
180 numverts++) {
181 /* just counting the vertexes */
182 }
183
184 for (i = 0; i < numverts; i++) {
185 double x1=pgon[i][X];
186 double y1=pgon[i][Y];
187 double x2=pgon[(i + 1) % numverts][X];
188 double y2=pgon[(i + 1) % numverts][Y];
189 double d=(y - y1) * (x2 - x1) - (x - x1) * (y2 - y1);
190
191 if ((y1 >= y) != (y2 >= y)) {
192 crossings +=y2 - y1 >= 0 ? d >= 0 : d <= 0;
193 }
194 if (!d && fmin(x1,x2) <= x && x <= fmax(x1,x2)
195 && fmin(y1,y2) <= y && y <= fmax(y1,y2)) {
196 return 1;
197 }
198 }
199 return crossings & 0x01;
200}
201
202
203static int is_closer(const double point[2], double coords[MAXVERTS][2],

Callers 1

imap_handler_internalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected