15 #include <Eigen/Dense> 69 std::vector<mrpt::math::TPoint3D>&
71 std::vector<mrpt::math::TPoint3D>&
74 bool forceScaleToUnity)
80 TPoint3D ct_others(0, 0, 0), ct_this(0, 0, 0);
81 const size_t nMatches = points_this.size();
86 for (
size_t i = 0; i < nMatches; i++)
88 ct_others += points_other[i];
89 ct_this += points_this[i];
92 const double F = 1.0 / nMatches;
99 for (
size_t i = 0; i < nMatches; i++)
101 points_this[i] -= ct_this;
102 points_other[i] -= ct_others;
104 S(0, 0) += points_other[i].x * points_this[i].x;
105 S(0, 1) += points_other[i].x * points_this[i].y;
106 S(0, 2) += points_other[i].x * points_this[i].z;
108 S(1, 0) += points_other[i].y * points_this[i].x;
109 S(1, 1) += points_other[i].y * points_this[i].y;
110 S(1, 2) += points_other[i].y * points_this[i].z;
112 S(2, 0) += points_other[i].z * points_this[i].x;
113 S(2, 1) += points_other[i].z * points_this[i].y;
114 S(2, 2) += points_other[i].z * points_this[i].z;
120 N(0, 0) = S(0, 0) + S(1, 1) + S(2, 2);
121 N(0, 1) = S(1, 2) - S(2, 1);
122 N(0, 2) = S(2, 0) - S(0, 2);
123 N(0, 3) = S(0, 1) - S(1, 0);
126 N(1, 1) = S(0, 0) - S(1, 1) - S(2, 2);
127 N(1, 2) = S(0, 1) + S(1, 0);
128 N(1, 3) = S(2, 0) + S(0, 2);
132 N(2, 2) = -S(0, 0) + S(1, 1) - S(2, 2);
133 N(2, 3) = S(1, 2) + S(2, 1);
138 N(3, 3) = -S(0, 0) - S(1, 1) + S(2, 2);
143 vector<double> eigvals;
150 sqrt(
v[0] *
v[0] +
v[1] *
v[1] +
v[2] *
v[2] +
v[3] *
v[3]) - 1.0) <
163 for (
unsigned int i = 0; i < 4; i++)
164 out_transform[i + 3] =
v[i];
168 if (forceScaleToUnity)
176 for (
size_t i = 0; i < nMatches; i++)
185 s = std::sqrt(
num / den);
190 ct_others.x, ct_others.y, ct_others.z, pp.
x, pp.
y, pp.
z);
193 out_transform[0] = ct_this.
x - pp.
x;
194 out_transform[1] = ct_this.
y - pp.
y;
195 out_transform[2] = ct_this.z - pp.
z;
204 const std::vector<mrpt::math::TPoint3D>& in_points_this,
205 const std::vector<mrpt::math::TPoint3D>& in_points_other,
207 bool forceScaleToUnity)
211 std::vector<mrpt::math::TPoint3D> points_this = in_points_this;
212 std::vector<mrpt::math::TPoint3D> points_other = in_points_other;
215 points_this, points_other, out_transform, out_scale, forceScaleToUnity);
221 bool forceScaleToUnity)
224 const size_t N = corrs.size();
225 std::vector<mrpt::math::TPoint3D> points_this(N), points_other(N);
226 for (
size_t i = 0; i < N; i++)
228 points_this[i].x = corrs[i].this_x;
229 points_this[i].y = corrs[i].this_y;
230 points_this[i].z = corrs[i].this_z;
231 points_other[i].x = corrs[i].other_x;
232 points_other[i].y = corrs[i].other_y;
233 points_other[i].z = corrs[i].other_z;
236 points_this, points_other, out_transform, out_scale, forceScaleToUnity);
double x
X,Y,Z coordinates.
bool eig_symmetric(Derived &eVecs, std::vector< Scalar > &eVals, bool sorted=true) const
Read: eig()
void composePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixed< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixed< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point G such as .
T square(const T x)
Inline function for the square of a number.
This base provides a set of functions for maths stuff.
bool se3_l2_internal(std::vector< mrpt::math::TPoint3D > &points_this, std::vector< mrpt::math::TPoint3D > &points_other, mrpt::poses::CPose3DQuat &out_transform, double &out_scale, bool forceScaleToUnity)
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
double x() const
Common members of all points & poses classes.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
bool se3_l2(const mrpt::tfest::TMatchingPairList &in_correspondences, mrpt::poses::CPose3DQuat &out_transform, double &out_scale, bool forceScaleToUnity=false)
Least-squares (L2 norm) solution to finding the optimal SE(3) transform between two reference frames ...
Functions for estimating the optimal transformation between two frames of references given measuremen...