local w={}function w.map(w,z,g,H,C)if g==z then error("\082\097\110\103\101 \111\102 \122\101\114\111")end return((w-z)*(C-H))/(g-z)+H end function w.lerp(w,z,g)return w+(z-w)*g end function w.lawOfCosines(w,z,g)local H=((w*w+z*z)-g*g)/((2*w)*z)local C=math.acos(H)if C~=C then return nil end return C end function w.round(w,z)z=z or 1 return math.floor(w/z+.5)*z end function w.roundUp(w,z)return math.ceil(w/z)*z end function w.roundDown(w,z)return math.floor(w/z)*z end return w
--- Holds utilty math functions not available on Roblox's math library
-- @module Math

local Math = {}

--- Maps a number from one range to another
function Math.map(num, min0, max0, min1, max1)
	if max0 == min0 then
		error("Range of zero")
	end

	return (((num - min0)*(max1 - min1)) / (max0 - min0)) + min1
end

--- Interpolates betweeen two numbers, given an percent
-- @tparam {number} num0 Number
-- @tparam {number} num1 Second number
-- @tparam {number} percent The percent, a number in the range that will be used to define
--              how interpolated it is between num0 and num1
-- @treturn {number} The interpolated
function Math.lerp(num0, num1, percent)
	return num0 + ((num1 - num0) * percent)
end

--- Solving for angle across from c
function Math.lawOfCosines(a, b, c)
	local l = (a*a + b*b - c*c) / (2 * a * b)
	local angle = math.acos(l)
	if angle ~= angle then
		return nil
	end
	return angle
end

--- Round the given number to given precision
-- @tparam {number} number
-- @tparam[opt=1] {number} precision
function Math.round(number, precision)
	precision = precision or 1
	return (math.floor((number/precision)+0.5)*precision)
end

function Math.roundUp(number, precision)
	return math.ceil(number/precision) * precision
end

function Math.roundDown(number, precision)
	return math.floor(number/precision) * precision
end

return Math