Red Huang

Red Huang

射线投射算法

struct Point {double x, y;} p [10]; // 十个顶点的多边形

bool point_in_polygon(Point& t)
{
bool c = false;
for (int i = 0, j = 10-1; i t.y) != (p[j].y > t.y) &&
t.x < (p[j].x-p[i].x)*(t.y-p[i].y)/(p[j].y-p[i].y)+p[i].x)
c = !c;
return c;
}

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。