比较完美的点在多边行内得判断(c++)(转载)
2007-08-22 15:24
453 查看
比较完美的点在多边行内得判断(c++) |
inline int isLeft( CPoint *P0, CPoint *P1, CPoint *P2 ) { return ( (P1->x - P0->x) * (P2->y - P0->y) - (P2->x - P0->x) * (P1->y - P0->y) ); } bool CPointInPolygonDlg::PointPolygonAlgorithm(CPoint *pt) { int wn = 0; // the winding number counter int j=0; std::vector<CPoint *>::iterator it; // loop through all edges of the polygon for (it=vPolygon.begin(); it<vPolygon.end()-1; it++)// edge from V[i] to V[i+1] { j++; if ((*(it))->y <= pt->y) { // start y <= pt->y if ((*(it+1))->y > pt->y) // an upward crossing if (isLeft( *it, *(it+1), pt) > 0) // P left of edge ++wn; // have a valid up intersect } else { // start y > P.y (no test needed) if ((*(it+1))->y <= pt->y) // a downward crossing if (isLeft( *it, *(it+1), pt) < 0) // P right of edge --wn; // have a valid down intersect } } if (wn==0) return false; return true; } |
相关文章推荐
- 比较完美的点在多边行内得判断(c++)
- 使用JS判断是否数字和小数点组合的数字的两中方法比较-isNaN和逐判断[转载]
- 【转载】去重判断,比较字符串相似度
- 点在多边行内的判断(c++)
- [转载]比较完美的日期验证正则表达式(已修正)
- asp.net2.0导出pdf文件完美解决方案[转载]
- 转载一篇比较靠谱的CS学习历程,十年实现了全部这些,膜拜~
- 判断Java空字符串三种方法的比较
- (转载)管理员组获取系统权限的完美解决方案
- C#静态方法与非静态方法的比较 <转载>
- 判断 iframe 是否加载完成的完美方法
- 转载 C++学习推荐书目 比较中肯的读书经验
- 单例模式八种写法比较 2017-07-04 15:30 25人阅读 评论(0) 收藏 举报 分类: Android移动互联(19) 版权声明:本文为博主原创文章,未经博主允许不得转载。 目录
- 转载 C#中静态类和非静态类比较
- 判断与比较PHP的版本
- Android 完美高仿的微信源码(转载)
- South——完美替代django比较鸡肋的syncdb
- 一个比较完美的spacerdiv技巧
- 判断网络 比较苦逼 无法判断路由器 的WiFi 是否连接到网络
- [转载]较为完美的一种标题缩略显示方法