Subject: CGAL users discussion list
List archive
- From: Sebastien Loriot <>
- To:
- Subject: Re: [cgal-discuss] squared_distance and to_double producing NaN
- Date: Thu, 01 Oct 2009 18:38:51 +0200
Martin Mörth wrote:
Hello Everybody!Hello Martin,
I am calculating distances between points and segments. I isolated a
case where the computation seems to be returning a bad value (double
that is not a number).
] typedef CGAL::Simple_homogeneous< double > CgKernel;
] ] typedef CgKernel::FT CgFieldNumber;
] typedef CgKernel::Point_2 CgPoint;
] typedef CgKernel::Segment_2 CgSegment;
] ] std::stringstream text
] (
] "-2.0527819641170391e+142 1.5399153216416277e+142 1.2075326642268196e+139
" // p
] "-1.3832287034884996e+069 9.6657090977844965e+068 7.5794164096585707e+065
" // s.min
] "2509.7485796014098 1275.2576940874201 1.0" // s.max
] );
] ] CgPoint p;
] CgSegment s;
] ] text >> p;
] text >> s;
] ] CgFieldNumber field_number_dist = CGAL::squared_distance( p, s );
] double dist = CGAL::to_double( field_number_dist );
] ] assert( _fpclass( dist ) == _FPCLASS_QNAN /* Quiet NaN */ );
Approximate cartesian coordinates for the objects involved are:
] p -1699.9804849431803 1275.2576946873996
] s.min -1824.9804849431800 1275.2576947042162
] s.max 2509.7485796014098 1275.2576940874201
The point is very close to the segment. I am not sure whether
producing a NaN is the behaviour one would have to expect given
the kernel I use.
I do not see your point. You are using a floating point number type
inside your kernel, so the expected behaviour is that you can get NaN.
You probably should have a look at http://www.cgal.org/philosophy.html
Sebastien.
Maybe someone with more insight into the
distance calculation implementation can shed some light on this.
I am using CGAL 3.4 and VS 8.0 on Windows XP.
Thanks in advance for any help!
Martin
- [cgal-discuss] squared_distance and to_double producing NaN, Martin Mörth, 10/01/2009
- Re: [cgal-discuss] squared_distance and to_double producing NaN, Sebastien Loriot, 10/01/2009
- Re: [cgal-discuss] squared_distance and to_double producing NaN, Martin Mörth, 10/02/2009
- Re: [cgal-discuss] squared_distance and to_double producing NaN, Sebastien Loriot, 10/01/2009
Archive powered by MHonArc 2.6.16.