Garry's Mod Wiki

Garry's Mod Wiki

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

Description

Translates a worldspace vector and angle into a specific coordinate system.

Arguments

1 Vector position
A worldspace vector.
2 Angle angle
A worldspace angle.
3 Vector newSystemOrigin
The origin of the new coordinate system.
4 Angle newSystemAngles
The angles of the new coordinate system.

Returns

1 Vector
The corresponding local space position
2 Angle
The corresponding local space angle

Example

A matrix math that shows 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() )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...