Transforms: combining rotation and translation in one transformation
Atlasbot · 17/8/2026 · 10 min read
The Matrix article in Robotics left an open question: a pure rotation/expansion matrix can only transform a vector around the origin (0,0) — it cannot be used to move a point to another position. But a sensor mounted on the robot is both translation and rotation relative to the robot's center. Homogeneous transform is a way to combine both transformations into exactly one matrix.
Key concepts
Math tip: add a third component (always 1) to the 2D vector, turning (x, y) into (x, y, 1) — called homogeneous coordinates. With this extended vector, a 3×3 matrix can represent both rotation and translation in exactly one multiplication:
| cos θ −sin θ tx | | x | | x' |
| sin θ cos θ ty | × | y | = | y' |
| 0 0 1 | | 1 | | 1 |
The two columns tx, ty are the translation part; The 2×2 block in the upper left corner is the rotation learned in the Matrix lesson. This is exactly the type of tf2 matrix used internally to store and calculate all transformations between coordinate systems.
In short: "Transform" between two coordinate systems = a pair (rotation, translation) combined into a homogeneous matrix — correctly answers the question "how far and how much is this point deviating between system A and system B".
How it works
The biggest benefit of homogeneous transform: joining multiple consecutive transformations is just multiplying matrices together:
T_map→base_link = T_map→odom × T_odom→base_link
T_map→lidar = T_map→base_link × T_base_link→lidar
This is how tf2 answers the question "what coordinates does this point in the lidar_link system correspond to in the map system" — just multiply transforms consecutively along the path between two nodes in the TF tree.
Not all transforms change continuously:
static_transform_publisher → base_link → lidar_link (fixed, measured once at assembly)
odom_publisher (runs continuously) → odom → base_link (changes continuously according to odometry)
amcl (runs periodically) → map → odom (changes every time AMCL adjusts)
Technical details
Formulas
tf2 often needs to be calculated in both directions — knowing T_A→B, sometimes needing T_B→A (the opposite direction). Since the rotation matrix is orthogonal (orthogonal), the inverse of the rotation is simply transpose, eliminating the need for costly full matrix inversion:
T⁻¹: rotation R⁻¹ = Rᵀ (transpose, not inverse each element)
translation t' = −Rᵀ × t
For example: T_base_link→lidar has R rotated 0° (no rotation), t = (0.1, 0, 0.15)
T_lidar→base_link has R⁻¹ = Rᵀ = R (not rotated so displacement = itself)
t' = −(0.1, 0, 0.15) = (−0.1, 0, −0.15)
Parameters
In real ROS2, tf2 works with full 3D space, not just 2D as the examples in this column illustrate:
| Dimension of space | Homogeneous matrix size | The rotation part is used |
|---|---|---|
| 2D (illustrated in the article) | 3×3 | Angle θ is simple |
| 3D (actually used TF2) | 4×4 | Quaternion (learned in the previous lesson), not Euler |
Practical applications
When the robot detects an obstacle via LiDAR at local coordinates in the lidar_link system, determining the actual localization of that obstacle on the global map is the multiplication of the transform chain mentioned in the Principle of Operation section: T_map→lidar × local_point. The entire Nav2 pipeline updates the costmap (cost map used to avoid obstacles) dozens of times per second based on exactly this homogeneous matrix multiplication — understanding the underlying mathematics helps accurately diagnose when an obstacle is "in the wrong position" on the map: the error can be in any transform in the chain (wrong static transform when installing the sensor, or a cumulative error in odom→base_link), not necessarily a sensor error.
Practical example
import numpy as np
def homogeneous_transform(theta, tx, ty):
return np.array([
[np.cos(theta), -np.sin(theta), tx],
[np.sin(theta), np.cos(theta), ty],
[0, 0, 1]
])
# odom -> base_link: robot has gone to (2, 0), rotated 90 degrees
T_odom_base = homogeneous_transform(np.radians(90), 2, 0)
# base_link -> lidar_link: LiDAR fixedly installed, offset 0.1m in x
T_base_lidar = homogeneous_transform(0, 0.1, 0)
T_odom_lidar = T_odom_base @ T_base_lidar
point_lidar = np.array([1, 0, 1]) # point 1m ahead of LiDAR
point_odom = T_odom_lidar @ point_lidar
print(f"Diem trong he odom: ({point_odom[0]:.2f}, {point_odom[1]:.2f})")
Output:
Diem trong he odom: (2.00, 3.10)
The result is the correct combination of both transform layers in one calculation: robot position (2,0) rotation 90°, plus LiDAR offset 0.1m and LiDAR distance point 1m ahead — all calculated correctly just by successively multiplying homogeneous matrices, no need to write separate manual coordinate addition/subtraction logic for each step.
Common mistakes
- Calculate the inverse transform by inverting each element — as mentioned in the Formula section, the correct inverse of the rotation part is transpose, not taking
1/valueof each element — calculating this wrong way gives a completely meaningless result geometrically. - Wrong transform direction (parent→child or child→parent) — applying
T_map→odomwhen actually neededT_odom→map(the opposite direction) results in completely wrong coordinates even though there are no syntax errors. - Consider the static transform as "never needing to be updated" — if the sensor is disassembled and reinstalled (maintenance, replaced) without measuring and updating the corresponding static transform value, any position calculations based on the old transform will deviate by a fixed amount, difficult to detect because there are no runtime errors.
- Accumulating floating-point errors through long transform chains — multiplying multiple matrices consecutively over a long time can cause the rotation to gradually lose perfect orthogonality (no longer correct
RRᵀ = I) — needs periodic normalization, similar to the problem of quaternion normalization mentioned in the previous article.
Conclusion
Homogeneous transform is a unified mathematical tool that combines rotation and translation into a single matrix multiplication, allowing the chaining of multiple coordinate systems simply by successive matrix multiplications — this is exactly the mechanism tf2 uses to answer all the "where is this point in that system" questions. This is also the last article of the Math for Robotics section — Vector, Matrix, Coordinate System, Rotation, Quaternion, and Transform just learned is the full set of mathematical tools for the next section: kinematics Robot, where these formulas are applied directly to the real motion of mobile robots.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.