# Rotation: 90 deg around Z r = R.from_euler('z', 90, degrees=True) t = np.array([1.0, 0.0, 0.0]) T = np.eye(4) T[:3,:3] = r.as_matrix() T[:3, 3] = t 4. Applying the Transformation Transform a 3D point ( p = (0, 1, 0) ) from frame A to frame B.
Vector3d p_a(0.0, 1.0, 0.0); Vector3d p_b = T_ab * p_a; std::cout << "p_b: " << p_b.transpose() << std::endl; // Expected: after 90° Z rot: (0,1,0) -> (-1,0,0) then + translation (1,0,0) -> (0,0,0)
SE3d T_ba = T_ab.inverse();
T_ac = T_ab @ T_bc Order matters. The rightmost transform is applied first to the point. 6. Inversion The inverse of a rigid transform ( T_ab ) is ( T_ba ). It rotates by ( R^T ) and translates by ( -R^T t ).
In robotics, computer vision, and 3D graphics, the ability to represent rotations and translations in 3D space is fundamental. The Rigid3D object (often found in libraries like Sophus , Eigen , geometry_msgs , or tf2 ) is the industry-standard way to do this. Unlike a 4x4 homogeneous matrix, Rigid3D separates rotation (SO(3)) and translation, offering better numerical stability and mathematical clarity. rigid3d tutorial
SE3d T_ab = SE3d(q_ab, t_ab); SE3d T_bc = SE3d(q_bc, t_bc); SE3d T_ac = T_ab * T_bc;
// Rotation: 90 deg around Z Quaterniond q = Quaterniond(Eigen::AngleAxisd(M_PI/2, Vector3d::UnitZ())); Vector3d t(1.0, 0.0, 0.0); SE3d T_ab(q, t); // Transformation from frame A to frame B # Rotation: 90 deg around Z r = R
[ p_B = R_AB \cdot p_A + t_AB ]