Merge pull request #1435 from Kenshiin13/get-heading-from-coords

feat(common/modules/math): Add ESX.Math.GetHeadingFromCoords
This commit is contained in:
Arctos2win
2024-11-02 15:54:12 +01:00
committed by GitHub
@@ -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 = origin.x - target.x
local dy = origin.y - target.y
local heading = math.deg(math.atan(dy, dx)) + 90
return (heading + 360) % 360
end