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;
}

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。