Red Huang

Red Huang

Ray Casting Algorithm

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

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.