From: Mikko Rasa Date: Tue, 4 Jun 2019 13:37:36 +0000 (+0300) Subject: Move the Knot struct out of Spline X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=23583f28679d722e7354c1aa9951731e3dc79726;p=libs%2Fmath.git Move the Knot struct out of Spline It doesn't depend on the degree of the spline, so this will generate less different types and make it easier to create splines of different degrees from the same knots. --- diff --git a/source/interpolate/spline.h b/source/interpolate/spline.h index 67c8df0..c801188 100644 --- a/source/interpolate/spline.h +++ b/source/interpolate/spline.h @@ -3,6 +3,7 @@ #include #include +#include "knot.h" #include "polynomial.h" namespace Msp { @@ -24,6 +25,17 @@ struct SplineValue static Type make(const T *v) { return *v; } }; +template +struct SplineKnot +{ + typedef typename SplineValue::Type Value; + T x; + Value y; + + SplineKnot(): x(T()) { } + SplineKnot(T x_, const Value &y_): x(x_), y(y_) { } +}; + /** Stores a spline of degree D. It is a piecewise polynomial function with value continuity. Derivatives are not guaranteed to be continuous. @@ -39,15 +51,7 @@ class Spline { public: typedef typename SplineValue::Type Value; - - struct Knot - { - T x; - Value y; - - Knot(): x(T()) { } - Knot(T x_, const Value &y_): x(x_), y(y_) { } - }; + typedef SplineKnot Knot; struct Segment {