diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-07-03 09:39:33 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-07-03 09:39:33 +0000 |
| commit | dc87fc8833a417e1b663f1726d13674dc0990b8c (patch) | |
| tree | 6c38f537822882a1ebe884b72c816e0567419383 /src/2geom/piecewise.h | |
| parent | Check that objects are of the right type before casting them. (diff) | |
| download | inkscape-dc87fc8833a417e1b663f1726d13674dc0990b8c.tar.gz inkscape-dc87fc8833a417e1b663f1726d13674dc0990b8c.zip | |
Partial 2geom update (anticipating changes that will be part of the next major update anyway, so overwriting them on next update is not a problem)
(bzr r6125)
Diffstat (limited to 'src/2geom/piecewise.h')
| -rw-r--r-- | src/2geom/piecewise.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h index 8992c0097..96e64bcf9 100644 --- a/src/2geom/piecewise.h +++ b/src/2geom/piecewise.h @@ -704,7 +704,23 @@ Piecewise<T> derivative(Piecewise<T> const &a) { } std::vector<double> roots(Piecewise<SBasis> const &f); -Piecewise<SBasis> reverse(Piecewise<SBasis> const &f); + +template<typename T> +Piecewise<T> reverse(Piecewise<T> const &f) { + Piecewise<T> ret = Piecewise<T>(); + ret.cuts.resize(f.cuts.size()); + ret.segs.resize(f.segs.size()); + double start = f.cuts[0]; + double end = f.cuts.back(); + for (unsigned i = 0; i < f.cuts.size(); i++) { + double x = f.cuts[f.cuts.size() - 1 - i]; + ret.cuts[i] = end - (x - start); + } + for (unsigned i = 0; i < f.segs.size(); i++) + ret.segs[i] = reverse(f[f.segs.size() - i - 1]); + return ret; +} + } |
