feat(common/modules/math): Add ESX.Math.GetHeadingFromCoords

This commit is contained in:
Ilias Rbayti
2024-11-01 15:15:52 +01:00
parent f7dad8b021
commit 0ea7f3e144
@@ -36,3 +36,15 @@ function ESX.Math.Random(minRange, maxRange)
return math.random(minRange or 1, maxRange or 10)
end
---@param origin vector
---@param target vector
---@return number
function ESX.Math.GetHeadingFromCoords(origin, target)
local dx = target.x - origin.x
local dy = target.y - origin.y
local heading = math.deg(math.atan(dy, dx)) + 90
return (heading + 360) % 360
end