vgl_h_matrix_1d_compute_3point.cxx
Go to the documentation of this file.
1 // This is core/vgl/algo/vgl_h_matrix_1d_compute_3point.cxx
3 #include <cassert>
4 #ifdef _MSC_VER
5 # include <vcl_msvc_warnings.h>
6 #endif
7 
8 //
9 // computes 1d Moebius map from three point correspondences :
10 //
11 static void
12 direct_compute(double T[2][2],
13  double p11,double p12,double p13,// p1 p2 p3
14  double p21,double p22,double p23,
15 
16  double q11,double q12,double q13,// q1 q2 q3
17  double q21,double q22,double q23)
18 {
19  double A[2][2],B[2][2];
20  double t;
21 
22  t=+(p22*p13-p12*p23); A[0][0]=t*p11; A[1][0]=t*p21;
23  t=-(p21*p13-p11*p23); A[0][1]=t*p12; A[1][1]=t*p22;
24 
25  t=+(q22*q13-q12*q23); B[0][0]=t*q11; B[1][0]=t*q21;
26  t=-(q21*q13-q11*q23); B[0][1]=t*q12; B[1][1]=t*q22;
27 
28  T[0][0]= B[0][0]*A[1][1]-B[0][1]*A[1][0];
29  T[1][0]= B[1][0]*A[1][1]-B[1][1]*A[1][0];
30  T[0][1]=-B[0][0]*A[0][1]+B[0][1]*A[0][0];
31  T[1][1]=-B[1][0]*A[0][1]+B[1][1]*A[0][0];
32 }
33 
35 compute_cool_homg(const std::vector<vgl_homg_point_1d<double> >& points1,
36  const std::vector<vgl_homg_point_1d<double> >& points2,
38 {
39  assert(points1.size() == 3);
40  assert(points2.size() == 3);
41  double T[2][2];
42  direct_compute(T,
43  points1[0].x() , points1[1].x() , points1[2].x(),
44  points1[0].w() , points1[1].w() , points1[2].w(),
45 
46  points2[0].x() , points2[1].x() , points2[2].x(),
47  points2[0].w() , points2[1].w() , points2[2].w());
48  H.set(&T[0][0]);
49  return true;
50 }
bool compute_cool_homg(const std::vector< vgl_homg_point_1d< double > > &points1, const std::vector< vgl_homg_point_1d< double > > &points2, vgl_h_matrix_1d< double > &H) override
A class to hold a line-to-line projective transformation matrix and to perform common operations usin...
Definition: vgl_algo_fwd.h:10
vgl_h_matrix_1d & set(T const *M)
Set to 2x2 row-stored matrix.
Calculate the line projectivity which matches three 1D point correspondences.
Represents a homogeneous 1-D point, i.e., a homogeneous pair (x,w).
Definition: vgl_fwd.h:7