Garry's Mod Wiki

PhysObj:LocalToWorldVector

  Vector PhysObj:LocalToWorldVector( Vector LocalVec )

Description

Rotate a vector from the local frame of the physics object to world frame.

This function only rotates the vector, without any translation operation.

Arguments

1 Vector LocalVec
A vector in the physics object's local frame

Returns

1 Vector
The corresponding vector in world frame

Example

Given the angle of the physics object is angle ( 0.045, 89.952, 89.99 ) ( This can be derived by PhysObj:GetAngles() ), convert the vector ( 1 ,2, 3 ) in this physics object's local frame into world frame.

print( "Angle of the PhysObj: ", PhysObj:GetAngles() ) print( "Vector in world frame: ", PhysObj:LocalToWorld( Vector( 1, 2, 3 ) ) )
Output: Angle of the PhysObj: 0.045 89.952 89.993; Vector in world frame: 3.000585 0.999039 1.999603;