20 const Eigen::Vector6d &pose,
21 const Eigen::Vector3d &source_mean,
22 const Eigen::Vector3d &target_mean) {
23 const Eigen::Vector3d g = pose.head<3>();
24 const double g_norm = g.norm();
25 const double theta = std::atan(g_norm);
27 Eigen::Matrix3d half_rotation = Eigen::Matrix3d::Identity();
29 half_rotation = Eigen::AngleAxisd(theta, g / g_norm).toRotationMatrix();
34 const Eigen::Matrix3d rotation = half_rotation * half_rotation;
35 const Eigen::Vector3d translation =
36 target_mean + half_rotation * (pose.tail<3>() * std::cos(theta)) -
37 rotation * source_mean;
39 Eigen::Matrix4d transformation = Eigen::Matrix4d::Identity();
40 transformation.block<3, 3>(0, 0) = rotation;
41 transformation.block<3, 1>(0, 3) = translation;
42 return transformation;