Subject: CGAL users discussion list
List archive
- From: Sylvain Pion <>
- To:
- Subject: Re: [cgal-discuss] point lying over a line problem
- Date: Wed, 23 Jul 2008 19:52:22 +0200
Alejandro Aragon a écrit :
By the way, quoting the FAQ:
"If your program does not involve the construction of new objects from the input data (such as the intersection of two objects, or the center of a sphere defined by the input objects), the CGAL::Exact_predicates_inexact_constructions_kernel kernel provides a nice and fast way to use exact predicates together with an inexact number type such as double for constructions."
Now, I modified my little example:
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <iostream>
using std::cout;
using std::endl;
using namespace CGAL;
int main() {
typedef CGAL::Exact_predicates_inexact_constructions_kernel KernelType;
typedef KernelType::Point_2 PointType;
typedef KernelType::Line_2 LineType;
PointType p(0.034,0.006);
cout<<"point -> "<<p<<endl;
LineType l(-0.004, 0.004, 0.000112);
cout<<"line -> "<<l<<endl;
CGAL::Oriented_side test = l.oriented_side(p);
if ( test == CGAL::ON_POSITIVE_SIDE ) {
cout<<"point on positive side"<<endl;
} else if ( test == CGAL::ON_NEGATIVE_SIDE ) {
cout<<"point on negative side"<<endl;
} else {
cout<<"point over line"<<endl;
}
return 0;
}
Result of the program:
$./a.out
point -> 0.034 0.006
line -> -0.004 0.004 0.000112
point on negative side
so where did the exact predicate stated in the kernel go??? Is this supposed to work like this? or this is finally a bug?
No bug, sorry.
You may know that 0.004 in C++ is a floating-point literal whose value
is not the real value 0.004, but the nearest (to simplify) representable
double to this value. So, the real value which is further considered
by CGAL is not 0.004, but this approximation.
This is not CGAL's fault, CGAL cannot do anything about this.
If you add cout.precision(20), this will change the output of your program,
and may give you some hints.
If you specify your coordinates as FT(4)/FT(1000), then you are guaranteed
(with an exact *constructions* kernel), that things will go fine.
--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
- Re: [cgal-discuss] point lying over a line problem, (continued)
- Re: [cgal-discuss] point lying over a line problem, Olivier Devillers, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Olivier Devillers, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Fernando Cacciola, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Andreas Fabri, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Sylvain Pion, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Sylvain Pion, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Sylvain Pion, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Sylvain Pion, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Fernando Cacciola, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Camille Wormser, 07/23/2008
- RE: [cgal-discuss] point lying over a line problem, Xiaofan Li, 07/24/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Sylvain Pion, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Alejandro Aragon, 07/23/2008
- Re: [cgal-discuss] point lying over a line problem, Olivier Devillers, 07/23/2008
Archive powered by MHonArc 2.6.16.