document and use std::tie
parent
8fa76865cb
commit
a1b73b3776
|
@ -66,6 +66,8 @@ GTSAM_EXPORT Point3 mean(const CONTAINER& points) {
|
||||||
sum = std::accumulate(points.begin(), points.end(), sum);
|
sum = std::accumulate(points.begin(), points.end(), sum);
|
||||||
return sum / points.size();
|
return sum / points.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// mean of Point3 pair
|
||||||
GTSAM_EXPORT Point3Pair mean(const std::vector<Point3Pair>& abPointPairs);
|
GTSAM_EXPORT Point3Pair mean(const std::vector<Point3Pair>& abPointPairs);
|
||||||
|
|
||||||
template <typename A1, typename A2>
|
template <typename A1, typename A2>
|
||||||
|
|
|
@ -99,9 +99,8 @@ Point3 Similarity3::operator*(const Point3& p) const {
|
||||||
// Refer to: http://www5.informatik.uni-erlangen.de/Forschung/Publikationen/2005/Zinsser05-PSR.pdf Chapter 3
|
// Refer to: http://www5.informatik.uni-erlangen.de/Forschung/Publikationen/2005/Zinsser05-PSR.pdf Chapter 3
|
||||||
Similarity3 Similarity3::AlignGivenR(const std::vector<Point3Pair>& abPointPairs, const Rot3& aRb) {
|
Similarity3 Similarity3::AlignGivenR(const std::vector<Point3Pair>& abPointPairs, const Rot3& aRb) {
|
||||||
// calculate centroids
|
// calculate centroids
|
||||||
const Point3Pair centroids = mean(abPointPairs);
|
Point3 aCentroid, bCentroid;
|
||||||
const Point3 aCentroid = centroids.first;
|
std::tie(aCentroid, bCentroid) = mean(abPointPairs);
|
||||||
const Point3 bCentroid = centroids.second;
|
|
||||||
|
|
||||||
// calculate scale
|
// calculate scale
|
||||||
double x = 0;
|
double x = 0;
|
||||||
|
@ -128,9 +127,8 @@ Similarity3 Similarity3::Align(const std::vector<Point3Pair>& abPointPairs) {
|
||||||
if (n < 3) throw std::runtime_error("input should have at least 3 pairs of points"); // we need at least three pairs
|
if (n < 3) throw std::runtime_error("input should have at least 3 pairs of points"); // we need at least three pairs
|
||||||
|
|
||||||
// calculate centroids
|
// calculate centroids
|
||||||
const Point3Pair centroids = mean(abPointPairs);
|
Point3 aCentroid, bCentroid;
|
||||||
const Point3 aCentroid = centroids.first;
|
std::tie(aCentroid, bCentroid) = mean(abPointPairs);
|
||||||
const Point3 bCentroid = centroids.second;
|
|
||||||
|
|
||||||
// Add to form H matrix
|
// Add to form H matrix
|
||||||
Matrix3 H = Z_3x3;
|
Matrix3 H = Z_3x3;
|
||||||
|
@ -152,7 +150,7 @@ Similarity3 Similarity3::Align(const std::vector<Pose3Pair>& abPosePairs) {
|
||||||
const size_t n = abPosePairs.size();
|
const size_t n = abPosePairs.size();
|
||||||
if (n < 2) throw std::runtime_error("input should have at least 2 pairs of poses"); // we need at least two pairs
|
if (n < 2) throw std::runtime_error("input should have at least 2 pairs of poses"); // we need at least two pairs
|
||||||
|
|
||||||
// calculate rotation and centroids
|
// calculate rotation
|
||||||
vector<Rot3> rotationList;
|
vector<Rot3> rotationList;
|
||||||
vector<Point3Pair> abPointPairs;
|
vector<Point3Pair> abPointPairs;
|
||||||
abPointPairs.reserve(n);
|
abPointPairs.reserve(n);
|
||||||
|
|
Loading…
Reference in New Issue