From: jfbarraud Date: Sat, 8 Mar 2008 21:59:59 +0000 (+0000) Subject: 2Geom fix: derivative of order 1 bezier, and an out of range bug affecting intersecti... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6f3751d3cd1c07803378a0841c0b38ffeeb5c450;p=inkscape.git 2Geom fix: derivative of order 1 bezier, and an out of range bug affecting intersection computation. --- diff --git a/src/2geom/bezier.h b/src/2geom/bezier.h index bdc672a57..af6df0840 100644 --- a/src/2geom/bezier.h +++ b/src/2geom/bezier.h @@ -173,7 +173,8 @@ public: Coord d_[order()+1]; unsigned nn = n_derivs; if(nn > order()) - nn = order(); + //nn = order(); + nn = order()+1; for(unsigned i = 0; i < size(); i++) d_[i] = c_[i]; for(unsigned di = 0; di < nn; di++) { @@ -262,7 +263,8 @@ inline std::vector bezier_points(const D2 & a) { } inline Bezier derivative(const Bezier & a) { - if(a.order() == 1) return Bezier(0.0); + //if(a.order() == 1) return Bezier(0.0); + if(a.order() == 1) return Bezier(a.c_[1]-a.c_[0]); Bezier der(Bezier::Order(a.order()-1)); for(unsigned i = 0; i < a.order(); i++) { diff --git a/src/2geom/path.h b/src/2geom/path.h index 72c5d50fa..f314e6efa 100644 --- a/src/2geom/path.h +++ b/src/2geom/path.h @@ -236,11 +236,7 @@ public: return new BezierCurve(Geom::derivative(inner[X]), Geom::derivative(inner[Y])); else if (order == 1) { double dx = inner[X][1] - inner[X][0], dy = inner[Y][1] - inner[Y][0]; - if(dx == 0) return new BezierCurve<1>(Point(0,0), Point(0,0)); - double slope = dy / dx; - Geom::Point pnt; - if(slope == 0) pnt = Geom::Point(0, 0); else pnt = Geom::Point(slope, 1./slope); - return new BezierCurve<1>(pnt, pnt); + return new BezierCurve<1>(Point(dx,dy),Point(dx,dy)); } } diff --git a/src/2geom/sweep.cpp b/src/2geom/sweep.cpp index 08674ab2f..b9ef71b5c 100644 --- a/src/2geom/sweep.cpp +++ b/src/2geom/sweep.cpp @@ -82,6 +82,7 @@ std::vector > sweep_bounds(std::vector a, std::vecto open[n].push_back(ix); } i[n]++; + if(i[n]>=events[n].size()) {break;} n = (events[!n][i[!n]] < events[n][i[n]]) ? !n : n; } return pairs;