/* * icp6Dquatscale implementation * * Copyright (C) Flavia Grosan, Alex Tandrau, Dorit Borrmann, Andreas Nuechter * * Released under the GPL version 3. * */ /** @file * @brief Implementation of the ICP error function minimization via quaternions and scale factor * @author Flavia Grosan, Alex Tandrau. Jacobs University Bremen gGmbH, Germany. * @author Andreas Nuechter. Jacobs University Bremen gGmbH, Germany. * @author Dorit borrmann. Jacobs University Bremen gGmbH, Germany. */ #include "slam6d/icp6Dquatscale.h" #include "slam6d/globals.icc" #include using std::ios; using std::resetiosflags; using std::setiosflags; #include #include #include using std::cout; using std::cerr; using std::endl; /** * computes the rotation matrix consisting * of a rotation and translation that * minimizes the root-mean-square error of the * point pairs using the Quaternion method of Horn * PARAMETERS * vector of point pairs, rotation matrix * @param pairs Vector of point pairs (pairs of corresponding points) * @param *alignfx The resulting transformation matrix * @return Error estimation of the matching (rms) */ double icp6D_QUAT_SCALE::Point_Point_Align(const vector& pairs, double *alignfx, const double centroid_m[3], const double centroid_d[3]) { int n = pairs.size(); double sum = 0.0; double sums[2]; sums[0] = sums[1] = 0.0; // the quaternion double q[7]; double S[3][3]; // Cross Covariance Matrix double Q[4][4]; int i,j; // calculate the cross covariance matrix for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) S[i][j] = 0; for (i=0; i