X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fbezier.h;h=f3df458ac19bdefd80ae656e1c9c3d734a5e01ef;hp=449d7bde77271204aa2ff0e645fe7bef48f13443;hb=e35bf651e7ebfe4932e877780bb00397c41a7ec2;hpb=53579b1a949fa3e4e193f8dfba2064edbb123f57 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