From 2f5eb047d9e05be5e68549ef6b75070d2faa7d2f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 11 Oct 2008 11:16:23 -0400 Subject: Merging from trunk (bzr r6884) --- src/2geom/piecewise.cpp | 13 ++++++++++++- src/2geom/piecewise.h | 2 ++ src/2geom/rect.h | 12 ++++++++++++ src/2geom/sbasis.cpp | 4 ++-- src/2geom/transforms.h | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src/2geom') diff --git a/src/2geom/piecewise.cpp b/src/2geom/piecewise.cpp index 2d8638818..4c63b20df 100644 --- a/src/2geom/piecewise.cpp +++ b/src/2geom/piecewise.cpp @@ -158,7 +158,6 @@ std::vector roots(Piecewise const &f){ std::vector result; for (unsigned i=0; i rts=roots(f.segs[i]); - rts=roots(f.segs[i]); for (unsigned r=0; r roots(Piecewise const &f){ return result; } +std::vector > multi_roots(Piecewise const &f, std::vector const &values) { + std::vector > result(values.size()); + for (unsigned i=0; i > rts = multi_roots(f.segs[i], values); + for(unsigned j=0; j derivative(Piecewise const &a) { std::vector roots(Piecewise const &f); +std::vector >multi_roots(Piecewise const &f, std::vector const &values); + template Piecewise reverse(Piecewise const &f) { Piecewise ret = Piecewise(); diff --git a/src/2geom/rect.h b/src/2geom/rect.h index f8ac7a2f7..ee1b0d764 100644 --- a/src/2geom/rect.h +++ b/src/2geom/rect.h @@ -140,6 +140,18 @@ inline Rect unify(Rect const & a, Rect const & b) { return Rect(unify(a[X], b[X]), unify(a[Y], b[Y])); } +/** Returns the smallest rectangle that encloses both rectangles. + * An empty argument is assumed to be an empty rectangle */ +inline boost::optional unify(boost::optional const & a, boost::optional const & b) { + if (!a) { + return b; + } else if (!b) { + return a; + } else { + return unify(*a, *b); + } +} + inline Rect union_list(std::vector const &r) { if(r.empty()) return Rect(Interval(0,0), Interval(0,0)); Rect ret = r[0]; diff --git a/src/2geom/sbasis.cpp b/src/2geom/sbasis.cpp index 377238d92..a7e049def 100644 --- a/src/2geom/sbasis.cpp +++ b/src/2geom/sbasis.cpp @@ -70,9 +70,9 @@ bool SBasis::isFinite() const { std::vector SBasis::valueAndDerivatives(double t, unsigned n) const { std::vector ret(n+1); - ret.push_back(valueAt(t)); + ret[0]=valueAt(t); SBasis tmp = *this; - for(unsigned i = 0; i < n; i++) { + for(unsigned i = 1; i < n+1; i++) { tmp.derive(); ret[i] = tmp.valueAt(t); } diff --git a/src/2geom/transforms.h b/src/2geom/transforms.h index 898b095b5..d21c5c617 100644 --- a/src/2geom/transforms.h +++ b/src/2geom/transforms.h @@ -84,6 +84,7 @@ class Rotate { explicit Rotate(Coord x, Coord y) { Rotate(Point(x, y)); } inline operator Matrix() const { return Matrix(vec[X], vec[Y], -vec[Y], vec[X], 0, 0); } + inline Point vector() const { return vec; } inline Coord operator[](Dim2 const dim) const { return vec[dim]; } inline Coord operator[](unsigned const dim) const { return vec[dim]; } inline bool operator==(Rotate const &o) const { return vec == o.vec; } -- cgit v1.2.3