WorldToLocal
Vector, Angle WorldToLocal( Vector position, Angle angle, Vector newSystemOrigin, Angle newSystemAngles )
Description
Translates the specified position and angle into the specified coordinate system.
Arguments
Returns
Example
Matrix math which showcases how this is calculated internally.
local worldTransform = Matrix()
worldTransform:SetTranslation(position)
worldTransform:SetAngles(angle)
local objectTransform = Matrix()
objectTransform:SetTranslation(newSystemOrigin)
objectTransform:SetAngles(newSystemAngles)
-- Transform the world coordinates using the object transform as an inverted transformation matrix
local worldToLocal = objectTransform:GetInverse() * worldTransform
print(worldToLocal:GetTranslation(), worldToLocal:GetAngles())