diff --git a/vector.lua b/vector.lua index 6e25bd6..2d75d62 100644 --- a/vector.lua +++ b/vector.lua @@ -46,10 +46,8 @@ local function randomDirection(len_min, len_max) assert(len_max > 0, "len_max must be greater than zero") assert(len_max >= len_min, "len_max must be greater than or equal to len_min") - - local range = len_max - len_min - local rnd = math.random() * range - return fromPolar(math.random()*2*math.pi, + + return fromPolar(math.random() * 2*math.pi, math.random() * (len_max-len_min) + len_min) end