further improved accuracy of Delaunay triangulation (ticket #433)

This commit is contained in:
Vadim Pisarevsky 2010-11-10 20:45:54 +00:00
parent 728f0eb2f5
commit e6b2efeb11

View File

@ -331,12 +331,13 @@ exit:
CV_INLINE int CV_INLINE int
icvIsPtInCircle3( CvPoint2D32f pt, CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c ) icvIsPtInCircle3( CvPoint2D32f pt, CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
{ {
double val = (a.x * a.x + a.y * a.y) * cvTriangleArea( b, c, pt ); const double eps = FLT_EPSILON*0.125;
val -= (b.x * b.x + b.y * b.y) * cvTriangleArea( a, c, pt ); double val = ((double)a.x * a.x + (double)a.y * a.y) * cvTriangleArea( b, c, pt );
val += (c.x * c.x + c.y * c.y) * cvTriangleArea( a, b, pt ); val -= ((double)b.x * b.x + (double)b.y * b.y) * cvTriangleArea( a, c, pt );
val -= (pt.x * pt.x + pt.y * pt.y) * cvTriangleArea( a, b, c ); val += ((double)c.x * c.x + (double)c.y * c.y) * cvTriangleArea( a, b, pt );
val -= ((double)pt.x * pt.x + (double)pt.y * pt.y) * cvTriangleArea( a, b, c );
return val > FLT_EPSILON ? 1 : val < -FLT_EPSILON ? -1 : 0; return val > eps ? 1 : val < -eps ? -1 : 0;
} }
@ -618,9 +619,8 @@ cvCalcSubdivVoronoi2D( CvSubdiv2D * subdiv )
static int static int
icvIsRightOf2( const CvPoint2D32f& pt, const CvPoint2D32f& org, const CvPoint2D32f& diff ) icvIsRightOf2( const CvPoint2D32f& pt, const CvPoint2D32f& org, const CvPoint2D32f& diff )
{ {
Cv32suf cw_area; double cw_area = ((double)org.x - pt.x)*diff.y - ((double)org.y - pt.y)*diff.x;
cw_area.f = (org.x - pt.x)*diff.y - (org.y - pt.y)*diff.x; return (cw_area > 0) - (cw_area < 0);
return (cw_area.i > 0)*2 - (cw_area.i*2 != 0);
} }