浮動小数点数を使用して数回試みた結果、丸めの問題が原因でワイルド例外が発生した後、回避策として整数演算を使用するとうまくいくと思いました。しかし、今、まったく同じ問題に遭遇しました。
さまざまな点セットの凸包の交点を計算しようとしています:
#include <iostream>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/multi/geometries/multi_point.hpp>
#include <boost/geometry/geometries/polygon.hpp>
int main()
{
typedef boost::geometry::model::d2::point_xy<int> Point;
typedef boost::geometry::model::multi_point<Point> MultiPoint;
typedef boost::geometry::model::ring<Point> Polygon;
MultiPoint mp0, mp1;
boost::geometry::read_wkt("MULTIPOINT((54 74),(54 75),(54 75),(62 75),(86 75),(94 75),(118 75),(124 75),(13 50),(13 51),(147 130),(281 51),(281 50))", mp0);
boost::geometry::read_wkt("MULTIPOINT((52 74),(54 75),(135 90),(175 74),(54 74),(52 74))", mp1);
Polygon hull0, hull1;
boost::geometry::convex_hull(mp0, hull0);
boost::geometry::convex_hull(mp1, hull1);
std::vector<Polygon> results;
boost::geometry::intersection(hull0, hull1, results);
assert(results.size() == 1);
// This results in the exception.
assert(!boost::geometry::detail::overlay::has_self_intersections(results[0]));
return EXIT_SUCCESS;
}
これは で失敗しboost::geometry::overlay_invalid_input_exception
ます。
凸包は次のようhull0
になりhull1
ます。
私が間違っていることはありますか?凸包と交差の計算を自分で実装する必要がないようにしたいのですが、これは多くの不必要なエラーが発生しやすい作業のようです。