- Patch 8.0.1
This commit is contained in:
+47
-5
@@ -8,6 +8,9 @@ end
|
||||
local UnitExists = UnitExists
|
||||
local atan2 = math.atan2
|
||||
local pi = math.pi
|
||||
local abs = math.abs
|
||||
|
||||
SMALL_FLOAT = 0.000001
|
||||
|
||||
--find distance between two players
|
||||
function DF:GetDistance_Unit (unit1, unit2)
|
||||
@@ -45,7 +48,7 @@ function DF:MapRangeUnclamped (inputX, inputY, outputX, outputY, value)
|
||||
return DF:GetRangeValue (outputX, outputY, DF:GetRangePercent (inputX, inputY, value))
|
||||
end
|
||||
|
||||
--find the normalized percent fo the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
|
||||
--find the normalized percent of the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
|
||||
function DF:GetRangePercent (minValue, maxValue, value)
|
||||
return (value - minValue) / (maxValue - minValue)
|
||||
end
|
||||
@@ -55,12 +58,51 @@ function DF:GetRangeValue (minValue, maxValue, percent)
|
||||
return Lerp (minValue, maxValue, percent)
|
||||
end
|
||||
|
||||
--dot product of two vectors
|
||||
function DF:GetDotProduct (v1, v2)
|
||||
return (v1.x * v2.x) + (v1.y * v2.y)
|
||||
--dot product of two 2D Vectors
|
||||
function DF:GetDotProduct (value1, value2)
|
||||
return (value1.x * value2.x) + (value1.y * value2.y)
|
||||
end
|
||||
|
||||
--normalized value 0-1 result in the value on the range given, e.g 200-400 range with a value of .5 result in 300
|
||||
function DF:LerpNorm (minValue, maxValue, value)
|
||||
return (minValue + value * (maxValue - minValue))
|
||||
end
|
||||
end
|
||||
|
||||
--change the color by the deltaTime
|
||||
function DF:LerpLinearColor (deltaTime, interpSpeed, r1, g1, b1, r2, g2, b2)
|
||||
deltaTime = deltaTime * interpSpeed
|
||||
local r = r1 + (r2 - r1) * deltaTime
|
||||
local g = g1 + (g2 - g1) * deltaTime
|
||||
local b = b1 + (b2 - b1) * deltaTime
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
--check if a number is near another number by a tolerance
|
||||
function DF:IsNearlyEqual (value1, value2, tolerance)
|
||||
tolerance = tolerance or SMALL_FLOAT
|
||||
return abs (value1 - value2) <= tolerance
|
||||
end
|
||||
|
||||
--check if a number is near zero
|
||||
function DF:IsNearlyZero (value, tolerance)
|
||||
tolerance = tolerance or SMALL_FLOAT
|
||||
return abs (value) <= tolerance
|
||||
end
|
||||
|
||||
--check if a number is within a two other numbers, if isInclusive is true, it'll include the max value
|
||||
function DF:IsWithin (minValue, maxValue, value, isInclusive)
|
||||
if (isInclusive) then
|
||||
return ((value >= minValue) and (value <= maxValue))
|
||||
else
|
||||
return ((value >= minValue) and (value < maxValue))
|
||||
end
|
||||
end
|
||||
|
||||
--dont allow a number ot be lower or bigger than a certain range
|
||||
function DF:Clamp (minValue, maxValue, value)
|
||||
return value < minValue and minValue or value < maxValue and value or maxValue
|
||||
end
|
||||
|
||||
function DF:ScaleBack ()
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user