/// <summary> /// 判断点和直线的位置关系 /// </summary> /// <param name="LinePntA">直线上的一点</param> /// <param name="LinePntB">直线上的另一点</param> /// <param name="PntM">需要判断的点</param> /// <returns></returns> private int JudgePointToLine(Point3d LinePntA, Point3d LinePntB, Point3d PntM) { int nResult = 0; double ax = LinePntB.X - LinePntA.X; double ay = LinePntB.Y - LinePntA.Y; double bx = PntM.X - LinePntA.X; double by = PntM.Y - LinePntA.Y; double judge = ax * by - ay * bx; if (judge > 0) { nResult = 1; } else if (judge < 0) { nResult = -1; } else { nResult = 0; } return nResult; }