From 23583f28679d722e7354c1aa9951731e3dc79726 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 4 Jun 2019 16:37:36 +0300 Subject: [PATCH] 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. --- source/interpolate/spline.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 { -- 2.45.2