问题标签 [grahams-scan]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - 凸包不返回正确的路径(C++ 中的格雷厄姆扫描)
我已经完成了预期输出的算法:
p00 - p01 ,
p01 - p03 ,
p03 - p10 ,
p10 - p12 ,
p12 - p00
但我得到了这个:
凸包:
p00 - p01
p01 - p03
p03 - p05
p05 - p10
p10 - p00
点数:
p00: (-5,-6)
p01: (6,-4)
p02: (5.5,-3)
p03: (8,0)
p04: (5,0)
p05: (4,2) p06
: (1,3)
p07: (0,2) p08:
(-1,1)
p09: (-1.5,2)
p10: (-1.5,6)
p11: (-5.5,1.5)
p12: (-8, -1)
我一直在努力让它正确,但有些我做不到。任何人都可以帮忙吗?我正在使用 C++
下面是我的代码:
我有 3 个类Vector2D、Point2D和Point2DSet我的 Graham 扫描实现在 Point2DSet 的 buildConvexHull 函数中。
Vector2D.cpp
Point2D
Point2DSet
任何其他改进都受到热烈欢迎。谢谢你!