Resampler implemented

This commit is contained in:
Aditya Ujeniya
2024-08-21 09:47:16 +02:00
parent 362adab938
commit b186dca79d
7 changed files with 351 additions and 56 deletions

25
pkg/resampler/util.go Normal file
View File

@@ -0,0 +1,25 @@
package resampler
import (
"math"
"github.com/ClusterCockpit/cc-metric-store/internal/util"
)
func calculateTriangleArea(paX, paY, pbX, pbY, pcX, pcY util.Float) float64 {
area := ((paX-pcX)*(pbY-paY) - (paX-pbX)*(pcY-paY)) * 0.5
return math.Abs(float64(area))
}
func calculateAverageDataPoint(points []util.Float, xStart int64) (avgX util.Float, avgY util.Float) {
for _, point := range points {
avgX += util.Float(xStart)
avgY += point
xStart++
}
l := util.Float(len(points))
avgX /= l
avgY /= l
return avgX, avgY
}