restructured folder
This commit is contained in:
27
code/math.lua
Normal file
27
code/math.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
Reference in New Issue
Block a user