MFC 判断三个点是否共线
BOOL TheThreePointsAreCollinear(CPoint PrePoint, CPoint CurrentPoint, CPoint NextPoint)
{
BOOL flag=false;
if(PrePoint.y==CurrentPoint.y && CurrentPoint.y==NextPoint.y)//如果3个点的Y坐标都相等,则它们是共线的
flag = true;
else{
if(PrePoint.x==CurrentPoint.x){
if(CurrentPoint.x==NextPoint.x)//如果3个点的X坐标都相等,则它们是共线的
flag=true;
}
else{
if(NextPoint.y-PrePoint.y-(CurrentPoint.y-PrePoint.y)*(NextPoint.x-PrePoint.x)/(CurrentPoint.x-PrePoint.x) == 0)
flag = true;//如果第三个点的坐标值满足前两个点所确定的直线方程。则这三个点共线
}
}
return flag;
}