开发者

How to implement PNPOLY for CCMenuItem to define touchable areas of a non-rectangle polygon?

开发者 https://www.devze.com 2023-03-29 13:04 出处:网络
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/Homepag

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号