objectarx之判断三点是否在一条直线上

bool CCommonFuntion::IsOnLine(AcGePoint2d& pt1, AcGePoint2d& pt2, AcGePoint2d& pt3)
{
AcGeVector3d vec1 = AcGeVector3d(pt2.x - pt1.x, pt2.y - pt1.y, 0);
AcGeVector3d vec2 = AcGeVector3d(pt3.x - pt1.x, pt3.y - pt1.y, 0);
double pi = 3.14159265;// 35897931;
//double angle = vec1.angleTo(vec2);
double angle = ((int)((vec1.angleTo(vec2)) * 100000000 + 0.5)) / 100000000.0;
if (angle == pi || angle == 0)
return true;
else
return false;
}

原文地址:https://www.cnblogs.com/Pond-ZZC/p/11813607.html