Use Gmprat for Path bounds with TRANSFORM_BEZIERS_TO_PATH
[ipdf/code.git] / src / bezier.cpp
index 9d24672..daa0736 100644 (file)
@@ -4,6 +4,8 @@
 #include <cmath>
 #include <algorithm>
 
+
+
 using namespace std;
 
 namespace IPDF
@@ -54,9 +56,13 @@ static void CubicSolveSegment(vector<Real> & 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)", Double(tl), Double(l), Double(tu), Double(u));
+               //return;
+       }
        
        bool negative = (u < l); // lower point > 0, upper point < 0
+       //Debug("%ft^3 + %ft^2 + %ft + %f is negative (%f < %f) %d", Double(a),Double(b),Double(c),Double(d),Double(u),Double(l), negative);
        while (tu - tl > delta)
        {
                Real t(tu+tl);
@@ -97,23 +103,6 @@ vector<Real> 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;
-       */
 }
 
 /**
@@ -437,3 +426,4 @@ Rect Bezier::SolveBounds() const
 }
 
 } // end namespace
+

UCC git Repository :: git.ucc.asn.au