Type Function Object Body Library physics.* Return value Numbers Revision Release 2026.3728 Keywords body, local, world, vector See also object:getLinearVelocityFromWorldPoint() object:getLinearVelocityFromLocalPoint()
Transforms a vector from the body’s local coordinate system to the world coordinate system. The input vector (x, y) is expressed relative to the body’s center (in pixels), and the method returns the corresponding vector in world space (also in pixels), correctly accounting for the body’s rotation.
object:getWorldVector( x, y )
Number. The x component of the vector in local space (pixels).
Number. The y component of the vector in local space (pixels).
Two numbers: the x and y components of the rotated vector in world space (pixels). If the body is absent, nil is returned for both.
-- Create a rectangle and add a physics body local myRect = display.newRect( 100, 100, 60, 60 ) physics.addBody( myRect, "dynamic" ) -- Apply some rotation myRect.rotation = 45 -- Convert a local upward vector (pointing to the 'top' of the body) local wx, wy = myRect:getWorldVector( 0, -50 ) print( "World direction from local (0, -50): " .. wx .. ", " .. wy )