2 #ifndef vgl_compute_similarity_3d_hxx_ 3 #define vgl_compute_similarity_3d_hxx_ 10 #include <vnl/vnl_double_4.h> 11 #include <vnl/algo/vnl_svd.h> 12 #include <vnl/algo/vnl_determinant.h> 13 #include <vnl/vnl_matrix.h> 15 # include <vcl_msvc_warnings.h> 27 assert(points1.size() == points2.size());
34 points1_.push_back(p1);
35 points2_.push_back(p2);
55 for (
unsigned i=0; i<pts.size(); ++i)
60 for (
unsigned i=0; i<pts.size(); ++i)
76 for (
unsigned i=0; i<pts.size(); ++i)
78 s += (pts[i]-origin).
length();
80 s = std::sqrt(3.0)*pts.size()/s;
81 for (
unsigned i=0; i<pts.size(); ++i)
84 p.
set(p.
x()*s, p.
y()*s, p.
z()*s);
93 std::vector<vgl_point_3d<T> > pts1(points1_), pts2(points2_);
94 center_points(pts1, t1);
95 center_points(pts2, t2);
98 scale_points(pts2, s2);
99 scale_points(pts1, s1);
106 translation_ = (scale_*(rotation_*t1) - t2);
112 #undef VGL_COMPUTE_SIMILARITY_3D_INSTANTIATE 113 #define VGL_COMPUTE_SIMILARITY_3D_INSTANTIATE(T) \ 114 template class vgl_compute_similarity_3d<T > 116 #endif // vgl_compute_similarity_3d_hxx_ void center_points(std::vector< vgl_point_3d< T > > &pts, vgl_vector_3d< T > &t) const
center all the points at the origin, and return the applied translation.
void add_points(vgl_point_3d< T > const &p1, vgl_point_3d< T > const &p2)
add a pair of points to point sets.
Compute a similarity transformation between two corresponding sets of 3D points.
double length(v const &a)
Return the length of a vector.
vgl_compute_similarity_3d()=default
bool estimate()
estimates the similarity transformation from the stored points.
Compute a rigid transformation between two corresponding sets of 3D points.
const vgl_rotation_3d< T > & rotation() const
Access the estimated rotation.
bool estimate()
estimates the rigid transformation from the stored points.
Direction vector in Euclidean 3D space, templated by type of element.
void clear()
clear internal data.
void set(T vx, T vy, T vz)
Assignment.
void set(Type px, Type py, Type pz)
Set x, y and z.
void scale_points(std::vector< vgl_point_3d< T > > &pts, T &s) const
normalize the scale of the points, and return the applied scale.
The similarity transform that normalizes a 3-d point set.