embd/util/map.go

13 lines
286 B
Go
Raw Normal View History

2014-01-05 22:04:19 +01:00
// Package util contains utility functions.
2014-01-05 11:19:03 +01:00
package util
2014-01-05 22:04:19 +01:00
// Map re-maps a number from one range to another.
//
// Example:
//
// val := Map(angle, 0, 180, 1000, 2000)
//
2014-01-05 11:19:03 +01:00
func Map(x, inmin, inmax, outmin, outmax int64) int64 {
return (x-inmin)*(outmax-outmin)/(inmax-inmin) + outmin
}