Garry's Mod Wiki

PhysObj:LocalToWorldVector

  Vector PhysObj:LocalToWorldVector( Vector vecLocal )

Description

Transforms a vector in the local space of the physics object merely by the rotation of the PhysObj:GetPositionMatrix().

In contrast to PhysObj:LocalToWorld, this function doesn't translate the vector.

Arguments

1 Vector vecLocal
A vector in the physics object's local space.

Returns

1 Vector
The result vector of the transformation by rotation.

Example

Suppose... The angle of some physics object is ( 0.045, 89.952, 89.993 ). Transform a vector ( 1, 2, 3 ) by that physics object's position matrix's rotation.

print( "Angle of that some PhysObj: ", PhysObj:GetAngles() ) print( "The result vector: ", PhysObj:LocalToWorldVector( Vector( 1, 2, 3 ) ) )
Output:
Angle of that some PhysObj: 0.045 89.952 89.993 The result vector: 3.000585 0.999039 1.999603