Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Function GetOrthogonal for easier othogonalization of a 2 ve… #1619

Closed
wants to merge 13 commits into from
22 changes: 22 additions & 0 deletions garrysmod/lua/includes/extensions/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,25 @@ function util.RemovePData( steamid, name )
sql.Query( "DELETE FROM playerpdata WHERE infoid = "..SQLStr(name) )

end

--[[---------------------------------------------------------
Name: GetOrthogonalEx (vF, vU, bN )
Desc: Recalculates the orthogonality of right and up vectors
according to forward direction and planae origin vectors.
* vF > The forward direction for the orthogonalization process
* vD > The direction of the forward vector plane origin
* bN > When set to true, normalizes the three unit vectors
* vU, vR > The function returns the up and right vectors on success
-----------------------------------------------------------]]
function util.GetOrthogonalEx( vF, vD, bN )
local vR = vF:Cross( vD )
local vU = vR:Cross( vF )

if ( bN ) then
vF:Normalize()
vR:Normalize()
vU:Normalize()
end

return vU, vR
end