【问题标题】:Floating-point precision selection in CGALCGAL中的浮点精度选择
【发布时间】:2014-06-05 06:06:18
【问题描述】:

我想知道是否有办法让我选择 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 位算术下计算凸包。 (而且,是的,我愿意冒高舍入误差的风险。)

有没有在运行时或编译时选择浮点精度?

【问题讨论】:

  • 你可以试试Filtered_kernel&lt;Simple_cartesian&lt;float&gt;&gt;Simple_cartesian&lt;float&gt; 是您问题的直接答案,但您不应该这样做,您需要担心的不仅仅是舍入错误,算法可能会崩溃或无限循环。

标签: cgal


【解决方案1】:

您可以查看文件 Exact_predicates_inexact_constructions_kernel.h 并对其进行调整以创建您自己的精确谓词不精确的结构,但将数字存储在浮点数中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 2023-03-29
    • 2023-03-31
    • 2018-07-06
    • 2017-11-30
    • 2019-11-10
    • 1970-01-01
    相关资源
    最近更新 更多