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:
parent
74c208dc87
commit
0fb17676e2
1 changed files with 0 additions and 3 deletions
|
@ -241,9 +241,6 @@ func (s *CubicSpline) Prepare() error {
|
||||||
// last segments of the spline.
|
// last segments of the spline.
|
||||||
func (s *CubicSpline) Interpolate(x float64) float64 {
|
func (s *CubicSpline) Interpolate(x float64) float64 {
|
||||||
N := len(s.Points)
|
N := len(s.Points)
|
||||||
if N == 1 {
|
|
||||||
return s.Points[0].Y
|
|
||||||
}
|
|
||||||
if x < s.Points[0].X {
|
if x < s.Points[0].X {
|
||||||
// Comes before the start of the spline, extrapolate
|
// Comes before the start of the spline, extrapolate
|
||||||
return s.Points[0].Y + (x-s.Points[0].X)*s.Preslope
|
return s.Points[0].Y + (x-s.Points[0].X)*s.Preslope
|
||||||
|
|
Loading…
Reference in a new issue