-- https://stackoverflow.com/a/5732390


type Range = { number }

local function mapRange(n: number, input: Range, output: Range): number
	assert(input[1] ~= input[2], "input min and max must be different numbers to avoid dividing by zero")

	local slope = (output[2] - output[1]) / (input[2] - input[1])
	return slope * (n - input[1]) + output[1]
end

return mapRange
