diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/2geom/piecewise.h | 14 | ||||
| -rw-r--r-- | src/2geom/sbasis.h | 13 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h index 171599768..1d0fd93ba 100644 --- a/src/2geom/piecewise.h +++ b/src/2geom/piecewise.h @@ -73,12 +73,26 @@ class Piecewise { unsigned n = segN(t); return segs[n](segT(t, n)); } + std::vector<output_type> valueAndDerivatives(double t, unsigned cnt) const { + unsigned n = segN(t); + std::vector<output_type> ret, val = segs[n].valueAndDerivatives(segT(t, n), cnt); + double mult = 1; + for(unsigned i = 0; i < val.size(); i++) { + ret.push_back(val[i] * mult); + mult /= cuts[n+1] - cuts[n]; + } + return ret; + } //TODO: maybe it is not a good idea to have this? Piecewise<T> operator()(SBasis f); Piecewise<T> operator()(Piecewise<SBasis>f); inline unsigned size() const { return segs.size(); } inline bool empty() const { return segs.empty(); } + inline void clear() { + segs.clear(); + cuts.clear(); + } /**Convenience/implementation hiding function to add segment/cut pairs. * Asserts that basic size and order invariants are correct diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h index c7489e27d..82ff989e7 100644 --- a/src/2geom/sbasis.h +++ b/src/2geom/sbasis.h @@ -113,7 +113,18 @@ public: return valueAt(t); } - std::vector<double> valueAndDerivatives(double /*t*/, unsigned /*n*/) const { + std::vector<double> valueAndDerivatives(double t, unsigned n) const { + std::vector<double> ret; + if(n==1) { + ret.push_back(valueAt(t)); + return ret; + } + if(n==2) { + double der; + ret.push_back(valueAndDerivative(t, der)); + ret.push_back(der); + return ret; + } //TODO throwNotImplemented(); } |
