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

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.

Returns

1 Vector
Local position
2 Angle
Local angles

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