【发布时间】:2014-05-29 16:27:02
【问题描述】:
我在 CGAL 中遇到了一件奇怪的事情。我有一条线和一个应该在这条线上的点。这段代码
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
int main( ) {
CGAL::Line_2<Kernel> l(0.2, 1.0, -1.4);
std::cout << l.has_on(CGAL::Point_2<Kernel>(-3.0, 2.0)) << std::endl;
std::cout << l.y_at_x(-3.0).exact() << std::endl;
return 0;
}
产生输出:
0
36028797018963967/18014398509481984
好吧,也许Exact_predicates_exact_constructions_kernel 不够好...(为什么?)
我尝试改用CGAL::Quotient 定义的内核:
typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> Kernel;
int main( ) {
CGAL::Line_2<Kernel> l(0.2, 1.0, -1.4);
std::cout << l.has_on(CGAL::Point_2<Kernel>(-3.0, 2.0)) << std::endl;
std::cout << l.y_at_x(-3.0) << std::endl;
return 0;
}
结果对我来说更加神秘:
0
2/1
是我遗漏了什么还是一个错误?
【问题讨论】: