CGAL中的浮点精度选择

时间:2014-06-05 06:06:19

标签: cgal

我想知道是否有办法让我选择CGAL中使用的浮点位宽。

例如,以下代码只是从CGAL手册直接复制的凸包示例:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point_2;
typedef std::vector<Point_2> Points;
int main()
{
  Points points, result;
  points.push_back(Point_2(0,0));
  points.push_back(Point_2(10,0));
  points.push_back(Point_2(10,10));
  points.push_back(Point_2(6,5));
  points.push_back(Point_2(4,1));
  CGAL::convex_hull_2( points.begin(), points.end(), std::back_inserter(result) );
  std::cout << result.size() << " points on the convex hull" << std::endl;
  return 0;
}

但是,我不能选择点的坐标存储在32位或64位浮点数中。 我还希望选择凸包在32或64位算术下计算。 (而且,是的,我愿意承担高舍入错误的风险。)

无论如何在运行时或编译时选择浮点精度?

1 个答案:

答案 0 :(得分:2)

您可以查看文件Exact_predicates_inexact_constructions_kernel.h 并调整它以创建自己的确切谓词不精确的结构,但存储数字浮动