LoRaWAN-Signal-Mapping/common/Math.mjs

17 lines
366 B
JavaScript
Raw Normal View History

"use strict";
function normalise(value, { min : input_min, max: input_max }, { min : output_min, max: output_max }) {
return (
((value - input_min) / (input_max - input_min)) * (output_max - output_min)
) + output_min
}
function clamp(value, min, max) {
if(value > max) return max;
if(value < min) return min;
return value;
}
export { normalise, clamp };