Garry's Mod Wiki



  Vector, Angle WorldToLocal( Vector position, Angle angle, Vector newSystemOrigin, Angle newSystemAngles )


Translates the specified position and angle into the specified coordinate system.


1 Vector position
The position that should be translated from the current to the new system.
2 Angle angle
The angles that should be translated from the current to the new system.
3 Vector newSystemOrigin
The origin of the system to translate to.
4 Angle newSystemAngles
The angles of the system to translate to.


1 Vector
Local position
2 Angle
Local angles


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())

Special Pages



Render Time: 71ms

DB GetPage 43
Generate Html 9
SaveChanges (1) 7
Render Body 0
Render Sidebar 9