Added MapFloatBetween util-function

This commit is contained in:
2022-03-22 00:21:08 +01:00
parent 31e6b1cb5e
commit 8eb850d9fe
2 changed files with 22 additions and 0 deletions

View File

@@ -15,3 +15,11 @@ func check(err error) {
log.Fatal(err)
}
}
type Numeric interface {
float64
}
func MapFloatBetween[T Numeric](value, start1, stop1, start2, stop2 T) T {
return start2 + (value-start1)*(stop2-start2)/(stop1-start1)
}