I'm implementing a touchable rainbow but the concave 'transparent' areas of a upper band is interfering with the lower rainbow bands. I'm hoping to use PNPOLY from (http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html) but I don't understand how it is supposed to work. I'm hoping to define the band's touchable area and transparent (non-touchable) area.
Code:
int pnpoly(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;
}
The reference says the boolean expression for a concave entity is A.B.C.(D+E+F). How does this fit into the function?
精彩评论