Files
envi-code/SourceCode/Code2026/CoreLibrary/PointInPoly.cpp
T
2026-09-28 15:28:50 +08:00

13 lines
348 B
C++

#include "StdAfx.h"
int IsPointInPoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++)
{
if ( ( ( verty[i] > testy) != (verty[j] > testy)) &&
(testx < (vertx[j] - vertx[i]) * (testy - verty[i]) / (verty[j] - verty[i]) + vertx[i]) )
c = !c;
}
return c;
}