summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3cc77bb)
raw | patch | inline | side by side (parent: 3cc77bb)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Mar 2008 19:59:42 +0000 (19:59 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Mar 2008 19:59:42 +0000 (19:59 +0000) |
src/2geom/piecewise.h | patch | blob | history | |
src/2geom/sbasis.h | patch | blob | history |
diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h
index 1715997684cec7c7ccff95f8e893c0cd5fe9cdbf..1d0fd93baf17a9576f9b3b8b4481e974f2e44cba 100644 (file)
--- a/src/2geom/piecewise.h
+++ b/src/2geom/piecewise.h
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 c7489e27dcd9115ad621c76fcb9666b41d5cf0cb..82ff989e7b3d01e9b4501926bd02841dcf53bbc9 100644 (file)
--- a/src/2geom/sbasis.h
+++ b/src/2geom/sbasis.h
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();
}