contrib/oxl/mvl/HMatrix1DComputeDesign.cxx
Go to the documentation of this file.
00001 #include "HMatrix1DComputeDesign.h"
00002 
00003 #include <vcl_cassert.h>
00004 
00005 #include <vnl/algo/vnl_svd.h>
00006 #include <vgl/vgl_homg_point_1d.h>
00007 #include <mvl/HMatrix1D.h>
00008 
00009 //********************************************************************************
00010 //
00011 //
00012 //
00013 //********************************************************************************
00014 
00015 
00016 HMatrix1DComputeDesign::HMatrix1DComputeDesign(void) : HMatrix1DCompute() { }
00017 HMatrix1DComputeDesign::~HMatrix1DComputeDesign() { }
00018 
00019 bool
00020 HMatrix1DComputeDesign::compute_cool_homg(const vcl_vector<vgl_homg_point_1d<double> >&P,
00021                                           const vcl_vector<vgl_homg_point_1d<double> >&Q,
00022                                           HMatrix1D *M)
00023 {
00024   unsigned N=P.size(); assert(N==Q.size());
00025   vnl_matrix<double> D(N,4);
00026   for (unsigned i=0;i<N;i++) {
00027     D(i,0)=P[i].x()*Q[i].w();
00028     D(i,1)=P[i].w()*Q[i].w();
00029     D(i,2)=-P[i].x()*Q[i].x();
00030     D(i,3)=-P[i].w()*Q[i].x();
00031   }
00032   vnl_svd<double> svd(D);
00033   M->set(svd.nullvector().data_block());
00034   return true;
00035 }