Garry's Mod Wiki

LocalToWorld

Vector, Angle LocalToWorld( Vector localPos, Angle localAng, Vector originPos, Angle originAngle )

Description

Translates the specified position and angle from the specified local coordinate system into worldspace coordinates.

If you're working with an entity's local vectors, use Entity:LocalToWorld and/or Entity:LocalToWorldAngles instead.

See also: WorldToLocal, the reverse of this function.

Arguments

1 Vector localPos
The position vector in the source coordinate system, that should be translated to world coordinates
2 Angle localAng
The angle in the source coordinate system, that should be converted to a world angle. If you don't need to convert an angle, you can supply an arbitrary valid angle (e.g. Angle()).
3 Vector originPos
The origin point of the source coordinate system, in world coordinates
4 Angle originAngle
The angles of the source coordinate system, as a world angle

Returns

1 Vector
The world position of the supplied local position.
2 Angle
The world angles of the supplied local angle.

Example

Matrix math which showcases how this is calculated internally.

local localTransform = Matrix() localTransform:SetTranslation(localPos) localTransform:SetAngles(localAng) local worldTransform = Matrix() worldTransform:SetTranslation(originPos) worldTransform:SetAngles(originAngle) -- Transform the local coordinates using the world transform as a transformation matrix local localToWorld = worldTransform * localTransform print(localToWorld:GetTranslation(), localToWorld:GetAngles())

Page Links


Special Pages


Wikis

?

Render Time: 51ms

DB GetPage 3
Generate Html 19
SaveChanges (1) 15
Render Body 0
Render Sidebar 12