栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

优化/简化路径

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

优化/简化路径

更简单的方法。取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.


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/449365.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号