68 std::vector<mrpt::math::TPoint3D>&
70 std::vector<mrpt::math::TPoint3D>&
73 double& out_scale,
bool forceScaleToUnity)
79 TPoint3D ct_others(0, 0, 0), ct_this(0, 0, 0);
80 const size_t nMatches = points_this.size();
85 for (
size_t i = 0; i < nMatches; i++)
87 ct_others += points_other[i];
88 ct_this += points_this[i];
91 const double F = 1.0 / nMatches;
98 for (
size_t i = 0; i < nMatches; i++)
100 points_this[i] -= ct_this;
101 points_other[i] -= ct_others;
103 S.get_unsafe(0, 0) += points_other[i].x * points_this[i].x;
104 S.get_unsafe(0, 1) += points_other[i].x * points_this[i].y;
105 S.get_unsafe(0, 2) += points_other[i].x * points_this[i].z;
107 S.get_unsafe(1, 0) += points_other[i].y * points_this[i].x;
108 S.get_unsafe(1, 1) += points_other[i].y * points_this[i].y;
109 S.get_unsafe(1, 2) += points_other[i].y * points_this[i].z;
111 S.get_unsafe(2, 0) += points_other[i].z * points_this[i].x;
112 S.get_unsafe(2, 1) += points_other[i].z * points_this[i].y;
113 S.get_unsafe(2, 2) += points_other[i].z * points_this[i].z;
120 0, 0, S.get_unsafe(0, 0) + S.get_unsafe(1, 1) + S.get_unsafe(2, 2));
121 N.set_unsafe(0, 1, S.get_unsafe(1, 2) - S.get_unsafe(2, 1));
122 N.set_unsafe(0, 2, S.get_unsafe(2, 0) - S.get_unsafe(0, 2));
123 N.set_unsafe(0, 3, S.get_unsafe(0, 1) - S.get_unsafe(1, 0));
125 N.set_unsafe(1, 0, N.get_unsafe(0, 1));
127 1, 1, S.get_unsafe(0, 0) - S.get_unsafe(1, 1) - S.get_unsafe(2, 2));
128 N.set_unsafe(1, 2, S.get_unsafe(0, 1) + S.get_unsafe(1, 0));
129 N.set_unsafe(1, 3, S.get_unsafe(2, 0) + S.get_unsafe(0, 2));
131 N.set_unsafe(2, 0, N.get_unsafe(0, 2));
132 N.set_unsafe(2, 1, N.get_unsafe(1, 2));
134 2, 2, -S.get_unsafe(0, 0) + S.get_unsafe(1, 1) - S.get_unsafe(2, 2));
135 N.set_unsafe(2, 3, S.get_unsafe(1, 2) + S.get_unsafe(2, 1));
137 N.set_unsafe(3, 0, N.get_unsafe(0, 3));
138 N.set_unsafe(3, 1, N.get_unsafe(1, 3));
139 N.set_unsafe(3, 2, N.get_unsafe(2, 3));
141 3, 3, -S.get_unsafe(0, 0) - S.get_unsafe(1, 1) + S.get_unsafe(2, 2));
148 N.eigenVectors(Z, D);
149 Z.extractCol(Z.cols() - 1,
v);
153 sqrt(
v[0] *
v[0] +
v[1] *
v[1] +
v[2] *
v[2] +
v[3] *
v[3]) - 1.0) <
166 for (
unsigned int i = 0; i < 4; i++)
167 out_transform[i + 3] =
v[i];
171 if (forceScaleToUnity)
179 for (
size_t i = 0; i < nMatches; i++)
188 s = std::sqrt(
num / den);
193 ct_others.x, ct_others.y, ct_others.z, pp.
x, pp.
y, pp.
z);
196 out_transform[0] = ct_this.
x - pp.
x;
197 out_transform[1] = ct_this.
y - pp.
y;
198 out_transform[2] = ct_this.
z - pp.
z;
207 const std::vector<mrpt::math::TPoint3D>& in_points_this,
208 const std::vector<mrpt::math::TPoint3D>& in_points_other,
210 bool forceScaleToUnity)
214 std::vector<mrpt::math::TPoint3D> points_this = in_points_this;
215 std::vector<mrpt::math::TPoint3D> points_other = in_points_other;
218 points_this, points_other, out_transform, out_scale, forceScaleToUnity);
224 bool forceScaleToUnity)
227 const size_t N = corrs.size();
228 std::vector<mrpt::math::TPoint3D> points_this(N), points_other(N);
229 for (
size_t i = 0; i < N; i++)
231 points_this[i].x = corrs[i].this_x;
232 points_this[i].y = corrs[i].this_y;
233 points_this[i].z = corrs[i].this_z;
234 points_other[i].x = corrs[i].other_x;
235 points_other[i].y = corrs[i].other_y;
236 points_other[i].z = corrs[i].other_z;
239 points_this, points_other, out_transform, out_scale, forceScaleToUnity);