//判断两条直线是否相交
//每个线段的两点都在另一个线段的左右不同侧,则能断定线段相交
//公式对于向量(x1,y1)->(x2,y2),判断点(x3,y3)在向量的左边,右边,还是线上.
//p=x1(y3-y2)+x2(y1-y3)+x3(y2-y1).p<0 左侧, p=0 线上, p>0 右侧
BOOL ::IsLineSegmentCross(POINT pFirst1, POINT pFirst2, POINT pSecond1, POINT pSecond2)
{
long Linep1,Linep2;
//判断pSecond1和pSecond2是否在pFirst1->pFirst2两侧
Linep1 = pFirst1.x * (pSecond1.y - pFirst2.y) + pFirst2.x * (pFirst1.y - pSecond1.y) + pSecond1.x * (pFirst2.y - pFirst1.y);
Linep2 = pFirst1.x * (pSecond2.y - pFirst2.y) + pFirst2.x * (pFirst1.y - pSecond2.y) + pSecond2.x * (pFirst2.y - pFirst1.y);
if (((Linep1 ^ Linep2) >= 0) && !(Linep1 == 0 && Linep2 == 0))
{
//符号位异或为:pSecond1和pSecond2在pFirst1->pFirst2同侧
return FALSE;
}
//判断pFirst1和pFirst2是否在pSecond1->pSecond2两侧
Linep1 = pSecond1.x * (pFirst1.y - pSecond2.y)