admin
2025-04-14 fa5b069f9021a73210dcc45ebcc89883306372e6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include"utils.hpp"
 
bool panduan(std::vector<point>polygons, point p) {
    int num = 0;
 
    for (int i = 0; i < 4; i++) {
 
        point p1 = polygons[i % 4 % 4];
        point p2 = polygons[(i % 4 + 1) % 4];
 
        if (p1.y == p2.y) continue;
 
        if (p.y < std::min(p1.y, p2.y)) continue;
 
        if (p.y >= std::max(p1.y, p2.y)) continue;
 
        if (p.y == std::min(p1.y, p2.y)) {
            num++;
            continue;
        }
 
        float x = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;    //����ʽ 
 
        if (x > p.x) {
            num++;
        }
    }
 
    //printf("�������=%d\n", num);
 
    if (num & 1)
    {
        return true;//��������
    }
    else
    {
        return false;//��������
    }
 
}