mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(math): add normal to rotation method (#431)
This commit is contained in:
@@ -74,6 +74,21 @@ function math.tovector(input, min, max, round)
|
||||
error(('cannot convert %s to a vector value'):format(inputType), 2)
|
||||
end
|
||||
|
||||
---Tries to convert a surface Normal to a Rotation.
|
||||
---@param input vector3
|
||||
---@return vector3
|
||||
function math.normaltorotation(input)
|
||||
local inputType = type(input)
|
||||
|
||||
if inputType == 'vector3' then
|
||||
local pitch = -math.asin(input.y) * (180.0 / math.pi)
|
||||
local yaw = math.atan(input.x, input.z) * (180.0 / math.pi)
|
||||
return vec3(pitch, yaw, 0.0)
|
||||
end
|
||||
|
||||
error(('cannot convert type %s to a rotation vector'):format(inputType), 2)
|
||||
end
|
||||
|
||||
---Tries to convert its argument to a vector.
|
||||
---@param input string | table
|
||||
---@return number | vector2 | vector3 | vector4
|
||||
|
||||
Reference in New Issue
Block a user