X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fbezier.cpp;h=b3129e4f7ee4f3b36c651cfe7dc408e2bcd89a89;hp=a30a20a2afe72eade9b4642f99a1be3978132b69;hb=d9c0c3792133f87cd224dc22be428be8ddc016d8;hpb=53579b1a949fa3e4e193f8dfba2064edbb123f57 diff --git a/src/bezier.cpp b/src/bezier.cpp index a30a20a..b3129e4 100644 --- a/src/bezier.cpp +++ b/src/bezier.cpp @@ -59,8 +59,8 @@ static pair BezierTurningPoints(const Real & p0, const Real & p1, co { return pair(0, 1); } - Real a = (p1- p0 - 2*(p2-p1) + p3-p2); - Real b = (p1-p0 - (p2-p1))*(p1-p0); + Real a = (3*(p1-p2) + p3 - p0); + Real b = 2*(p2 - 2*p1 + p0); Real c = (p1-p0); if (a == 0) { @@ -71,9 +71,10 @@ static pair BezierTurningPoints(const Real & p0, const Real & p1, co if (t < 0) t = 0; return pair(t, t); } - Debug("a, b, c are %f, %f, %f", Float(a), Float(b), Float(c)); + //Debug("a, b, c are %f, %f, %f", Float(a), Float(b), Float(c)); if (b*b - 4*a*c < 0) { + //Debug("No real roots"); return pair(0,1); } pair tsols = SolveQuadratic(a, b, c); @@ -101,7 +102,7 @@ Rect Bezier::SolveBounds() const Evaluate(tp0, o, tsols.first); Evaluate(tp1, o, tsols.second); - Debug("x: tp0 is %f tp1 is %f", Float(tp0), Float(tp1)); + //Debug("x: tp0 is %f tp1 is %f", Float(tp0), Float(tp1)); vector v(4); v[0] = &x0; @@ -121,7 +122,7 @@ Rect Bezier::SolveBounds() const Evaluate(o, tp1, tsols.second); - Debug("y: tp0 is %f tp1 is %f", Float(tp0), Float(tp1)); + //Debug("y: tp0 is %f tp1 is %f", Float(tp0), Float(tp1)); v[0] = &y0; v[1] = &y3; @@ -132,7 +133,7 @@ Rect Bezier::SolveBounds() const result.y = *(v[0]); result.h = *(v[3]) - result.y; - Debug("Solved Bezier %s bounds as %s", Str().c_str(), result.Str().c_str()); + //Debug("Solved Bezier %s bounds as %s", Str().c_str(), result.Str().c_str()); return result; }