更简单的方法。取3个顶点a,b和c以及计算:顶点之间的角度/倾斜度。
std::vector<VERTEX> path;//fill pathstd::vector<int> removeList;//Assure that the value is in the same unit as the return of angleOf function.double maxTinyVariation = SOMETHING;for (int i = 0; i < quantity-2; ++i) { double a = path[i], b = path[i + 1] , c = path[i + 2] double abAngle = angleOf(a, b); double bcAngle = angleOf(b, c); if (abs(ab - bc) <= maxTinyVariation) { //a, b and c are colinear //remove b later removeList.push_back(i+1); }}//Remove vertecies from path using removeList.


