CGAL Segment_Delaunay_graph大数值精度问题咨询及解决方案求教
CGAL Segment_Delaunay_graph 数值误差问题咨询
经测试确认,CGAL的Segment_Delaunay_graph(SDG)在处理因微小数值计算误差导致的大数位输入时,无法得到正确结果;但对相同意图的输入进行数位舍入后,可生成正确结果。
核心问题
- 这是CGAL整体的算术问题,还是Segment_Delaunay_graph(SDG)的特定问题?
- 当前仅能通过输入补偿临时处理,但需将CAD等计算结果作为输入(这类输入必然引入微小误差),恳请提供可行的根本性解决方案建议。
测试案例
输入四个点构建两条相距较远的线段,目的是获取线段的输出单元作为闭合多边形:
void TestSDGWithError() { std::vector<SDG::Point_2> vpoints; vpoints.push_back(SDG::Point_2(199.9999999999996, 5699.9999999999991)); vpoints.push_back(SDG::Point_2(2199.9999999999845, 5700.0000000000009)); vpoints.push_back(SDG::Point_2(2199.999999999985, 0)); vpoints.push_back(SDG::Point_2(199.99999999999866, 0)); // Insertion of a point outside the domain to // make the Voronoi cell of the input line segment a finite cell CGAL::Bbox_2 bbox(-800, -1000, 3200, 6700); vpoints.push_back(SDG::Point_2(bbox.xmin(), bbox.ymin())); vpoints.push_back(SDG::Point_2(bbox.xmax(), bbox.ymin())); vpoints.push_back(SDG::Point_2(bbox.xmax(), bbox.ymax())); vpoints.push_back(SDG::Point_2(bbox.xmin(), bbox.ymax())); SDG dg; // insert points for (size_t i = 0; i < vpoints.size(); i++) dg.insert(SDG::Site_2::construct_site_2(vpoints[i])); // insert segments dg.insert(SDG::Site_2::construct_site_2(vpoints[0], vpoints[1])); dg.insert(SDG::Site_2::construct_site_2(vpoints[2], vpoints[3])); ....... }
测试结果对比
含微小数值误差的输入与舍入后数值的输入案例对比:
Test SDG With Error Closed Cell Polygon: 200.000, 6700.000 200.000, 2850.000 2200.000, 2850.000 2200.000, 2850.000 2200.000, 6700.000 1200.000, 88508786079941760.000 <<<< Error Vertex Closed Cell Polygon: ... Test SDG Without Error Closed Cell Polygon: 200.000, 2850.000 200.000, 2850.000 2200.000, 2850.000 2200.000, 2850.000 2200.000, 6700.000 1200.000, 8200.000 200.000, 6700.000 Closed Cell Polygon: ...
测试结果图示:粉色线条为输入SITE,绿色为对应的Cell。左侧为正确结果,右侧含误差,其中一个点向上发散。
内容的提问来源于stack exchange,提问作者ymzkd
相关产品推荐
相关产品推荐

