mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
Merge pull request #1435 from Kenshiin13/get-heading-from-coords
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 = origin.x - target.x
|
||||
local dy = origin.y - target.y
|
||||
|
||||
local heading = math.deg(math.atan(dy, dx)) + 90
|
||||
|
||||
return (heading + 360) % 360
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user