12 #if GMISC_NEED_HITTEST_POLY
23 if (a->
x < c->
x && b->
x < c->
x) {
30 if (c->
y <= a->
y && c->
y >= b->
y) {
36 if ((c->
x >= a->
x && c->
x <= b->
x) || (c->
x <= a->
x && c->
x >= b->
x)) {
51 crossProduct = (b->
x - a->
x) * (c->
y - a->
y) - (b->
y - a->
y) * (c->
x - a->
x);
54 if (crossProduct < 0) {
59 if (crossProduct == 0) {
69 gU8 nbrIntersection = 0;
73 for (i = 0; i < cnt-1; i++) {
75 if (pntarray[i].y >= pntarray[i+1].y) {
76 crossResult = _pointCrossingSegment(&pntarray[i], &pntarray[i+1], p);
78 crossResult = _pointCrossingSegment(&pntarray[i+1], &pntarray[i], p);
82 if (crossResult == 0) {
86 else if(crossResult == 1) {
94 if (pntarray[cnt-1].y >= pntarray[0].y) {
95 crossResult = _pointCrossingSegment(&pntarray[cnt-1], &pntarray[0], p);
97 crossResult = _pointCrossingSegment(&pntarray[0], &pntarray[cnt-1], p);
100 if (crossResult == 0) {
102 }
else if(crossResult == 1) {
107 if (nbrIntersection % 2 == 0) {
gI16 gCoord
The type for a coordinate or length on the screen.
gBool gmiscHittestPoly(const gPoint *pntarray, unsigned cnt, const gPoint *p)
Check whether a point is inside or on the edge of a polygon.
Type for a 2D point on the screen.