core/vpgl/algo/vpgl_ortho_procrustes.h
Go to the documentation of this file.
00001 // This is core/vpgl/algo/vpgl_ortho_procrustes.h
00002 #ifndef vpgl_ortho_procrustes_h_
00003 #define vpgl_ortho_procrustes_h_
00004 //:
00005 // \file
00006 // \brief Solve min(R,s) ||X-s(RY+t)||, where R is a rotation matrix, X,Y are 3-d points, s is a scalar and t is a translation vector.
00007 // \author J. L. Mundy
00008 // \date June 29, 2007
00009 //
00010 
00011 #include <vnl/vnl_fwd.h>
00012 #include <vgl/algo/vgl_rotation_3d.h>
00013 
00014 //: Solve orthogonal Procrustes problem
00015 // Solve the orthogonal Procrustes problem by finding a rotation matrix, R,
00016 // scale factor, s, and translation vector, t, that minimizes the distance
00017 // between two pointsets, X and Y, where Y is transformed to produce X.
00018 class vpgl_ortho_procrustes
00019 {
00020  public:
00021   //: only one constructor X and Y must both have dimensions 3 x N
00022   vpgl_ortho_procrustes(vnl_matrix<double> const& X,
00023                         vnl_matrix<double> const& Y);
00024 
00025   //: the resulting rotation matrix
00026   vgl_rotation_3d<double> R();
00027 
00028   //: the resulting translation vector
00029   vnl_vector_fixed<double, 3> t();
00030 
00031   //: The scale factor, s
00032   double s();
00033 
00034   //: the residual error
00035   double residual_mean_sq_error();
00036 
00037   //: successful computation
00038   bool compute_ok() const { return !cannot_compute_; }
00039 
00040  protected:
00041   //: No default constructor
00042   vpgl_ortho_procrustes();
00043   void compute();
00044 
00045   //: members
00046   bool cannot_compute_;
00047   bool computed_;
00048   vnl_matrix<double> X_;
00049   vnl_matrix<double> Y_;
00050   vgl_rotation_3d<double> R_;
00051   vnl_vector_fixed<double, 3> t_;
00052   double s_;
00053   double residual_;
00054 };
00055 
00056 #endif // vpgl_ortho_procrustes_h_