Revision Difference
Global.LocalToWorld#565515
<function name="LocalToWorld" parent="Global" type="libraryfunc">
<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 <page>Entity:LocalToWorld</page> and/or <page>Entity:LocalToWorldAngles</page> instead.
⤶
See also: <page>Global.WorldToLocal</page>, the reverse of this function.
Translates a vector and angle from a local coordinate system into a global coordinate system.
⤶
For the reverse of this function see <page>Global.WorldToLocal</page>.
⤶
For working with an entity's local space vectors/angles you might want to use <page>Entity:LocalToWorld</page>/<page>Entity:LocalToWorldAngles</page> instead.
</description>
<realm>Shared</realm>
<args>
<arg name="localPos" type="Vector">The position vector in the source coordinate system, that should be translated to world coordinates</arg>⤶
<arg name="localAng" type="Angle">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. <page>Global.Angle</page>()).</arg>⤶
<arg name="originPos" type="Vector">The origin point of the source coordinate system, in world coordinates</arg>⤶
<arg name="originAngle" type="Angle">The angles of the source coordinate system, as a world angle</arg>⤶
<arg name="localPos" type="Vector">A vector from a local coordinate system.</arg>⤶
<arg name="localAng" type="Angle">An angle from a local coordinate system.⤶
⤶
Pass a zero angle if you don't need to translate an angle.</arg>⤶
<arg name="originPos" type="Vector">The origin point of a global coordinate system, in worldspace coordinates.</arg>⤶
<arg name="originAngle" type="Angle">The angles of a global coordinate system, as a worldspace angle.</arg>⤶
</args>
<rets>
<ret name="" type="Vector">The world position of the supplied local position.</ret>
<ret name="" type="Angle">The world angles of the supplied local angle.</ret>
<ret name="" type="Vector">The correspondent worldspace vector of `localPos`.</ret>
<ret name="" type="Angle">The correspondent worldspace angle of `localAng`.</ret>
</rets>
</function>
<example>
<description>Matrix math which showcases how this is calculated internally.</description>
<description>A matrix math that shows how this is calculated internally.</description>
<code>
local localTransform = Matrix()
localTransform:SetTranslation(localPos)
localTransform:SetAngles(localAng)
local localTransform = Matrix()
localTransform:SetTranslation( localPos )
localTransform:SetAngles( localAng )
local worldTransform = Matrix()
worldTransform:SetTranslation(originPos)
worldTransform:SetAngles(originAngle)
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())
print( localToWorld:GetTranslation(), localToWorld:GetAngles() )
</code>
</example>
Garry's Mod
Rust
Steamworks
Wiki Help