X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbezier.h;h=f3df458ac19bdefd80ae656e1c9c3d734a5e01ef;hb=dfd021b1505fb3924ae103d8aa27c6200d6ec3fd;hp=449d7bde77271204aa2ff0e645fe7bef48f13443;hpb=53579b1a949fa3e4e193f8dfba2064edbb123f57;p=ipdf%2Fcode.git diff --git a/src/bezier.h b/src/bezier.h index 449d7bd..f3df458 100644 --- a/src/bezier.h +++ b/src/bezier.h @@ -11,8 +11,8 @@ namespace IPDF inline std::pair SolveQuadratic(const Real & a, const Real & b, const Real & c) { - Real x0((b + Sqrt(b*b - Real(4)*a*c))/(Real(2)*a)); - Real x1((b - Sqrt(b*b - Real(4)*a*c))/(Real(2)*a)); + Real x0((-b + Sqrt(b*b - Real(4)*a*c))/(Real(2)*a)); + Real x1((-b - Sqrt(b*b - Real(4)*a*c))/(Real(2)*a)); return std::pair(x0,x1); } @@ -64,11 +64,16 @@ namespace IPDF Rect SolveBounds() const; + Bezier ToAbsolute(const Rect & bounds) const + { + return Bezier(*this, bounds); + } + /** Convert absolute control points to control points relative to bounds * (This basically does the opposite of the Copy constructor) * ie: If this is absolute, the returned Bezier will be relative to the bounds rectangle */ - Bezier CopyInverse(const Rect & bounds) const + Bezier ToRelative(const Rect & bounds) const { // x' <- (x - x0)/w etc // special cases when w or h = 0