//HUNTON自己加的
int multiply(POINT P, POINT P1, POINT P2)
{
return((P2.y - P1.y) * (P.x - P1.x) + (P1.y - P.y) * (P2.x - P1.x));
}
//从原理上说,要找到一个对角线把多边形分成两个部分,然后对每个部分再重复生成对角线分割就可以得到多边形的一种三角形分割了。
POINT a_point_insidepoly(int vcount, POINT polygon[])
{
POINT v, a, b, r;
int i, index;
v = polygon[0];
index = 0;
float y2 = v.y; // new line
for(i = 1; i < vcount; i++){//寻找一个凸顶点,实际上最低点肯定是凸顶点
if(polygon[i].y < v.y){
y2 = v.y; // new line 次小的Y
v = polygon[i]; // 最小的 Y
index = i;
}
}
a = polygon[(index - 1 + vcount) % vcount]; //得到v的前一个顶点
b = polygon[(index + 1) % vcount]; //得到v的后一个顶点