function math.sign(x) if x<0 then return -1 elseif x>0 then return 1 else return 0 end end function vector(init_x, init_y, final_x, final_y) local distance_x = final_x - init_x local distance_y = final_y - init_y return {distance_x, distance_y} end function getVectorValue(vector) return math.sqrt(vector[1] ^ 2 + vector[2] ^ 2) end function getAngleFromVector(x,y) local reduce = 0 if x < 0 then reduce = math.rad(180) end return math.atan(y/x) - reduce end