mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 07:01:29 +00:00
feat(common/modules/math): Add ESX.Math.GetHeadingFromCoords
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user