Remove N=1 case from cubic interpolate

This lets Preslope and Postslope control slope either side of a
single point, which is probably more intuitive than just returning Y
of the point whenever Preslope and Postslope is provided.
This commit is contained in:
Josh Deprez 2021-10-05 10:24:01 +11:00
parent 74c208dc87
commit 0fb17676e2

View file

@ -241,9 +241,6 @@ func (s *CubicSpline) Prepare() error {
// last segments of the spline.
func (s *CubicSpline) Interpolate(x float64) float64 {
N := len(s.Points)
if N == 1 {
return s.Points[0].Y
}
if x < s.Points[0].X {
// Comes before the start of the spline, extrapolate
return s.Points[0].Y + (x-s.Points[0].X)*s.Preslope