Coordinate frames: read the same point from a robot and the world

Convert a fixed landmark between robot and world coordinates. Learn frame conventions, translation and rotation, inverse transforms, and point versus displacement.

By 9 min read

What you will learn

  • State which frame each coordinate pair and translation uses.
  • Convert a point between a planar body frame and world frame.
  • Explain why translating an origin affects points but not free displacements.
  • Check a frame conversion by recovering the original point and preserving distance.

Before you start

A landmark can be two meters to a robot's right while also sitting at world coordinate (3, 2). Both descriptions can be correct. A coordinate frame tells you where to start measuring and which directions count as positive.

We will keep one landmark fixed and change the robot's frame. At each robot pose, two coordinate pairs will describe that same physical point.

Choose an origin and axes

A Cartesian coordinate frame supplies an origin and perpendicular unit axes. The origin locates zero. The axes tell you how to interpret the coordinates of a point or displacement.

Use W for a world frame fixed to the floor and B for a body frame attached to the robot. The robot's position and heading describe how B sits in W. Lynch and Park introduce body and space frames this way in Modern Robotics.

For this planar example, world x points right on the diagram and world y points up. Body x points forward on the robot; body y points to its left. Both frames measure distances in meters.

The world frame is a chosen reference. Its origin need not be a special physical location. A consistent choice lets a map, robot, and sensor agree on what their numbers mean.

Read the frame subscripts

We use column vectors and this convention throughout:

SymbolMeaning
p_WThe landmark's coordinates in world frame W
p_BThe same landmark's coordinates in body frame B
t_WBThe body origin's position, expressed in W
R_WBThe rotation that converts body-coordinate displacements into world coordinates

Read R_WB as “from B into W.” Its columns are the body unit axes expressed in world coordinates. The translation t_WB also uses world coordinates, so its components can be added to a world-coordinate displacement.

A matrix named only rotation hides this information. Before using someone else's transform, check their definition of source frame, destination frame, vector layout, and units. The same letters can follow another convention.

Convert body coordinates into world coordinates

Let θ be the robot's heading, measured counterclockwise from world x to body x. Its rotation matrix is:

R_WB = [cos θ, −sin θ; sin θ, cos θ]

Semicolons separate rows. The first column is the body x direction in W. The second is the body y direction, a quarter-turn to its left.

Multiplying R_WB by p_B combines those two directions. Then add the world-coordinate position of the body origin:

p_W = R_WB p_B + t_WB

This calculation measures from the body origin along the body axes, then accounts for that origin's location. Modern Robotics represents the same rotation and translation together in a homogeneous transformation.

At θ = 0°, R_WB is the identity. The conversion becomes p_W = p_B + t_WB. With coincident origins as well, both coordinate pairs agree.

Subtract the origin, then change axes

To read a world landmark from the robot, first form p_W − t_WB. This is the displacement from the body origin to the landmark, still expressed along world axes.

The body axes are orthonormal, so the inverse rotation equals the transpose. Apply it after the subtraction:

p_B = R_WBᵀ(p_W − t_WB)

Each row of R_WBᵀ takes a dot product with one body unit axis. That extracts the displacement's forward and left components. Modern Robotics explains the unit columns and transpose-inverse property of rotation matrices.

The subtraction order matters. Expanding the expression gives R_WBᵀp_W − R_WBᵀt_WB. Subtracting the unrotated t_WB afterward would mix world and body components.

Locate a landmark from a turned robot

Place the body origin at t_WB = (1, 1) with heading 90°. Keep the landmark at p_W = (3, 2). The robot faces world +y, so its left side points toward world −x.

First subtract the body origin: p_W − t_WB = (2, 1). Then use the transpose of the quarter-turn matrix:

R_WB = [0, −1; 1, 0]
p_B = [0, 1; −1, 0](2, 1) = (1, −2)

The landmark is 1 meter forward and 2 meters right of the robot. A negative left component means right.

Check the forward conversion: R_WB(1, −2) = (2, 1). Adding (1, 1) returns (3, 2), the original world coordinates.

The distance from the robot origin is √(1² + (−2)²) = √5 meters. Using the world-coordinate displacement gives √(2² + 1²) = √5 too. The coordinate conversion preserves this distance.

Keep the landmark fixed

The initial diagram reproduces the worked example. The black landmark never changes its world position. The amber axes show where the robot's forward and left directions point.

World W and robot body B

Read one landmark in two frames

The landmark stays at (3, 2) meters in W. Move the body origin or turn its axes, then read its coordinates in B.

Fixed world landmark (3.000, 2.000) with body frame at (1.000, 1.000) and heading 90 degreesWorld axes use equal scales from minus 5 to 5 meters. The amber solid arrow is positive body x, and the amber dashed arrow is positive body y. The landmark has body coordinates (1.000, -2.000). Its distance from the body origin is 2.236 meters.-4-4-2-2002244x_Wy_W
World origin WBody origin BFixed landmarkBody x_B, forwardBody y_B, left
Grid numbers are world coordinates in meters. Arrow tips show positive axis directions; nested origin markers indicate coincident origins.

Positive headings turn counterclockwise from world x_W. Body x_B points forward; body y_B points left.

R_WB: body unit axes in world coordinates
ComponentBody xBody y
World x0.000-1.000
World y1.0000.000

Landmark in body B: (1.000, -2.000) m. Converting back gives (3.000, 2.000) m in world W.

Landmark in world W
(3.000, 2.000)
Body origin in world W
(1.000, 1.000)
Landmark in body B
(1.000, -2.000)
Converted back to world W
(3.000, 2.000)
Distance from body origin
2.236 m
Body heading
90°

All coordinate pairs use meters. R_WB maps body-coordinate displacements into world coordinates.

Choose Translation only to align the body axes with W while keeping the same origin. The body coordinates become (2, 1). Turning the heading changes those components, but the distance from the body origin stays √5.

Next choose At the landmark. The landmark becomes (0, 0) in B because the body origin now occupies that point. Its world coordinates remain (3, 2).

Translating the robot can change its distance to the landmark. Changing how a point is expressed between the two frames, at any one pose, leaves the physical point unchanged. The “Converted back to world W” readout checks that distinction after every edit.

Translate points, rotate displacements

Point coordinates depend on an origin. A free displacement vector describes the difference between two points. Subtracting their transformed coordinates cancels the origin translation:

q_W − p_W = R_WB(q_B − p_B)
d_W = R_WB d_B

At a 90° heading, the body displacement (2, 1) becomes world displacement (−1, 2). Adding the body's position to this result would turn a displacement conversion into a point conversion.

For a landmark, ‖p_B‖₂ = ‖p_W − t_WB‖₂ measures distance from the body origin. The quantity ‖p_W‖₂ measures distance from the world origin. Those distances generally differ because they start at different points.

This is the point-versus-vector distinction from vector spaces. A translated point-coordinate map is affine. Its displacement part is linear.

Extend the convention to 3D

In 3D, use three-coordinate points, a three-coordinate translation, and a 3×3 rotation. The same forward and reverse formulas apply. A proper rotation satisfies RᵀR = I and det(R) = +1.

A right-handed frame has unit axes satisfying x̂ × ŷ = ẑ. Our planar drawing fits this convention with +z pointing out of the page. Positive heading then follows the right-hand rule around +z.

ROS REP 103 specifies right-handed body axes with x forward, y left, and z up. It also describes camera optical frames with z forward, x right, and y down. Axis names alone do not establish which convention a sensor uses.

Document units too: ROS uses meters and radians for these quantities. This lesson's slider displays degrees for readability and converts them before using trigonometric functions.

Check a round trip in Python

This standard-library example follows the same convention as the widget. It uses floating-point trigonometry and rounds only the displayed values.

from math import cos, sin, radians, hypot, isclose

def world_to_body(point, origin, heading_degrees):
    angle = radians(heading_degrees)
    c, s = cos(angle), sin(angle)
    dx, dy = point[0] - origin[0], point[1] - origin[1]
    return (c * dx + s * dy, -s * dx + c * dy)

def body_to_world(point, origin, heading_degrees):
    angle = radians(heading_degrees)
    c, s = cos(angle), sin(angle)
    x, y = point
    return (c * x - s * y + origin[0],
            s * x + c * y + origin[1])

def vector_text(point):
    return f"({point[0]:.3f}, {point[1]:.3f})"

landmark = (3.0, 2.0)
origin = (1.0, 1.0)
heading = 90.0
local = world_to_body(landmark, origin, heading)
recovered = body_to_world(local, origin, heading)
print("Body coordinates:", vector_text(local))
print("Back in world:", vector_text(recovered))
print(f"Distance to body origin: {hypot(*local):.3f} m")
print("Round trip agrees:", all(
    isclose(a, b, rel_tol=0.0, abs_tol=1e-12)
    for a, b in zip(landmark, recovered)
))

Expected output:

Body coordinates: (1.000, -2.000)
Back in world: (3.000, 2.000)
Distance to body origin: 2.236 m
Round trip agrees: True

Try it yourself

Exercise 1. The robot origin is t_WB = (−1, 2), its heading is 0°, and a landmark has p_W = (2, 5). Find p_B. Convert the result back to W to check it.

Show solution: use the aligned axes

At 0°, the rotation is the identity. Subtract the body origin: p_B = (2, 5) − (−1, 2) = (3, 3).

The landmark is 3 meters forward and 3 meters left of the robot. Adding t_WB gives (3, 3) + (−1, 2) = (2, 5) in W.

Exercise 2. Use t_WB = (1, 1) and heading 90°. Two points have body coordinates p_B = (0, 0) and q_B = (2, 1). Find their world coordinates and the displacement from p to q. Does the displacement conversion include t_WB?

Show solution: subtract the converted points

The first point is the body origin, so p_W = (1, 1). Rotate the second point to (−1, 2), then add the translation to get q_W = (0, 3).

Subtracting gives d_W = q_W − p_W = (−1, 2). Rotating d_B = (2, 1) gives the same result. The translations cancel, so the displacement conversion contains only the rotation.

Sources and further study