X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fbezier.cpp;h=9b594a05f8fa24f9b821586b30f99b433a1104c4;hb=fe80b0a479a44182b6e7e982fb6ff33b6e17303d;hp=9d2467283ab47acb0df212787ee0aae24de10a30;hpb=8b3424a48d2d2e20de1a0e60ff6e1d84b9b5e226;p=ipdf%2Fcode.git diff --git a/src/bezier.cpp b/src/bezier.cpp index 9d24672..9b594a0 100644 --- a/src/bezier.cpp +++ b/src/bezier.cpp @@ -54,9 +54,11 @@ static void CubicSolveSegment(vector & roots, const Real & a, const Real & Real l = a*tl*tl*tl + b*tl*tl + c*tl + d; Real u = a*tu*tu*tu + b*tu*tu + c*tu + d; if ((l < 0 && u < 0) || (l > 0 && u > 0)) - return; + Debug("Discarding segment (no roots) l = %f (%f), u = %f (%f)", tl, l, tu, u); + //return; bool negative = (u < l); // lower point > 0, upper point < 0 + //Debug("%ft^3 + %ft^2 + %ft + %f is negative (%f < %f) %d", a,b,c,d,u,l, negative); while (tu - tl > delta) { Real t(tu+tl); @@ -97,23 +99,6 @@ vector SolveCubic(const Real & a, const Real & b, const Real & c, const Re tu = max; CubicSolveSegment(roots, a, b, c, d, tl, tu,delta); return roots; - /* - Real maxi(100); - Real prevRes(d); - for(int i = 0; i <= 100; ++i) - { - Real x(i); - x /= maxi; - Real y = a*(x*x*x) + b*(x*x) + c*x + d; - if (((y < Real(0)) && (prevRes > Real(0))) || ((y > Real(0)) && (prevRes < Real(0)))) - { - //Debug("Found root of %fx^3 + %fx^2 + %fx + %f at %f (%f)", a, b, c, d, x, y); - roots.push_back(x); - } - prevRes = y; - } - return roots; - */ } /**