unipdf/internal/imageutil/interpolate.go
Jacek Kucharczyk f0646b6f1f Minor image profiling tweaks.
Fixed minor and major issues with the naming and comments.
Added licenses information to files.
2020-07-15 11:37:13 +02:00

21 lines
461 B
Go

/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE.md', which is part of this source code package.
*/
package imageutil
import (
"math"
)
// LinearInterpolate is the simple linear interpolation from the PDF manual - PDF 32000-1:2008 - 7.10.2.
func LinearInterpolate(x, xmin, xmax, ymin, ymax float64) float64 {
if math.Abs(xmax-xmin) < 0.000001 {
return ymin
}
y := ymin + (x-xmin)*(ymax-ymin)/(xmax-xmin)
return y
}