diff --git a/libsrc/geom2d/csg2d.cpp b/libsrc/geom2d/csg2d.cpp index f97a0633..09f743b7 100644 --- a/libsrc/geom2d/csg2d.cpp +++ b/libsrc/geom2d/csg2d.cpp @@ -250,13 +250,20 @@ IntersectionType IntersectSplineSegment( const Spline & s, const Point<2> & r0, double det = b_*b_ - 4*a_*c_; if(det<0.0) return NO_INTERSECTION; - double sqrt_det = sqrt(det); - double t1 = 1.0/(2*a_) * (-b_ + sqrt_det); - double t2 = 1.0/(2*a_) * (-b_ - sqrt_det); - double t = min(t1,t2); - if(tEPSILON) + { + double sqrt_det = sqrt(det); + double t1 = 1.0/(2*a_) * (-b_ + sqrt_det); + double t2 = 1.0/(2*a_) * (-b_ - sqrt_det); + t = min(t1, t2); + if(t & r0, double det = b_*b_ - 4*a_*c_; if(det<0.0) return NO_INTERSECTION; + double sqrt_det = sqrt(det); double vbeta[2]; - vbeta[0] = 1.0/(2*a_) * (-b_ + sqrt_det); - vbeta[1] = 1.0/(2*a_) * (-b_ - sqrt_det); + + if(fabs(a_)>EPSILON) + { + vbeta[0] = 1.0/(2*a_) * (-b_ + sqrt_det); + vbeta[1] = 1.0/(2*a_) * (-b_ - sqrt_det); + } + else // degenrate quadratic equation + vbeta[0] = vbeta[1] = -c_/b_; int dim = fabs(vr[0]) > fabs(vr[1]) ? 0 : 1; double valpha[2];