37 #ifndef PCL_REGISTRATION_IMPL_TRANSFORMATION_ESTIMATION_3POINT_H_
38 #define PCL_REGISTRATION_IMPL_TRANSFORMATION_ESTIMATION_3POINT_H_
40 #include <pcl/common/eigen.h>
41 #include <pcl/registration/transformation_estimation_3point.h>
44 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline void
48 Matrix4 &transformation_matrix)
const
50 if (cloud_src.
points.size () != 3 || cloud_tgt.
points.size () != 3)
52 PCL_ERROR (
"[pcl::TransformationEstimation3Point::estimateRigidTransformation] Number of points in source (%lu) and target (%lu) must be 3!\n",
59 estimateRigidTransformation (source_it, target_it, transformation_matrix);
63 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
void
66 const std::vector<int> &indices_src,
68 Matrix4 &transformation_matrix)
const
70 if (indices_src.size () != 3 || cloud_tgt.
points.size () != 3)
72 PCL_ERROR (
"[pcl::TransformationEstimation3Point::estimateRigidTransformation] Number of indices in source (%lu) and points in target (%lu) must be 3!\n",
73 indices_src.size (), cloud_tgt.
points.size ());
79 estimateRigidTransformation (source_it, target_it, transformation_matrix);
83 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline void
86 const std::vector<int> &indices_src,
88 const std::vector<int> &indices_tgt,
89 Matrix4 &transformation_matrix)
const
91 if (indices_src.size () != 3 || indices_tgt.size () != 3)
93 PCL_ERROR (
"[pcl::TransformationEstimation3Point::estimateRigidTransformation] Number of indices in source (%lu) and target (%lu) must be 3!\n",
94 indices_src.size (), indices_tgt.size ());
100 estimateRigidTransformation (source_it, target_it, transformation_matrix);
104 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
void
109 Matrix4 &transformation_matrix)
const
111 if (correspondences.size () != 3)
113 PCL_ERROR (
"[pcl::TransformationEstimation3Point::estimateRigidTransformation] Number of correspondences (%lu) must be 3!\n",
114 correspondences.size ());
120 estimateRigidTransformation (source_it, target_it, transformation_matrix);
124 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar>
inline void
128 Matrix4 &transformation_matrix)
const
130 transformation_matrix.setIdentity ();
134 Eigen::Matrix <Scalar, 4, 1> source_mean, target_mean;
141 Eigen::Matrix <Scalar, Eigen::Dynamic, Eigen::Dynamic> source_demean, target_demean;
148 Eigen::Matrix <Scalar, 3, 1> s1 = source_demean.col (1).head (3) - source_demean.col (0).head (3);
151 Eigen::Matrix <Scalar, 3, 1> s2 = source_demean.col (2).head (3) - source_demean.col (0).head (3);
152 s2 -= s2.dot (s1) * s1;
155 Eigen::Matrix <Scalar, 3, 3> source_rot;
156 source_rot.col (0) = s1;
157 source_rot.col (1) = s2;
158 source_rot.col (2) = s1.cross (s2);
160 Eigen::Matrix <Scalar, 3, 1> t1 = target_demean.col (1).head (3) - target_demean.col (0).head (3);
163 Eigen::Matrix <Scalar, 3, 1> t2 = target_demean.col (2).head (3) - target_demean.col (0).head (3);
164 t2 -= t2.dot (t1) * t1;
167 Eigen::Matrix <Scalar, 3, 3> target_rot;
168 target_rot.col (0) = t1;
169 target_rot.col (1) = t2;
170 target_rot.col (2) = t1.cross (t2);
173 Eigen::Matrix <Scalar, 3, 3> R = target_rot * source_rot.transpose ();
174 transformation_matrix.topLeftCorner (3, 3) = R;
176 transformation_matrix.block (0, 3, 3, 1) = target_mean.head (3) - R * source_mean.head (3);
Iterator class for point clouds with or without given indices.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
void demeanPointCloud(ConstCloudIterator< PointT > &cloud_iterator, const Eigen::Matrix< Scalar, 4, 1 > ¢roid, pcl::PointCloud< PointT > &cloud_out, int npts=0)
Subtract a centroid from a point cloud and return the de-meaned representation.
unsigned int compute3DCentroid(ConstCloudIterator< PointT > &cloud_iterator, Eigen::Matrix< Scalar, 4, 1 > ¢roid)
Compute the 3D (X-Y-Z) centroid of a set of points and return it as a 3D vector.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences