1 // This is oxl/mvl/AffineMetric.h
2 #ifndef AffineMetric_h_
3 #define AffineMetric_h_
4 //:
5 // \file
6 // \brief AffineMetric is an ImageMetric that is an affine transformation.
7 // \author
8 //     Andrew W. Fitzgibbon, Oxford RRG, 24 Feb 97
9 //
10 // \verbatim
11 //  Modifications
12 //   22 Jun 2003 - Peter Vanroose - added vgl_homg_point_2d interface
13 // \endverbatim
14 //
15 //-----------------------------------------------------------------------------
16 
17 #include <iostream>
18 #include <iosfwd>
19 #include <vnl/vnl_double_3x3.h>
20 #include <vgl/vgl_fwd.h>
21 #include <mvl/ImageMetric.h>
22 #ifdef _MSC_VER
23 #  include <vcl_msvc_warnings.h>
24 #endif
25 
26 class AffineMetric : public ImageMetric
27 {
28   vnl_double_3x3 A_;
29   vnl_double_3x3 A_inverse_;
30  public:
31 
32   AffineMetric();
33   AffineMetric(vnl_double_3x3 const& A);
34 
35   vgl_point_2d<double> homg_to_image(vgl_homg_point_2d<double> const&) const override;
36   vnl_double_2 homg_to_image(const HomgPoint2D& p) const override;
37 
38   vgl_homg_point_2d<double> image_to_homg(vgl_point_2d<double> const&) const override;
39   HomgPoint2D image_to_homg(const vnl_double_2&) const override;
40   HomgPoint2D image_to_homg(double x, double y) const override;
41 
42   vgl_homg_point_2d<double> homg_to_imagehomg(vgl_homg_point_2d<double> const&) const override;
43   vgl_homg_point_2d<double> imagehomg_to_homg(vgl_homg_point_2d<double> const&) const override;
44 
45   HomgPoint2D homg_to_imagehomg(const HomgPoint2D& p) const override;
46   HomgPoint2D imagehomg_to_homg(const HomgPoint2D& p) const override;
47 
48   void set(vnl_double_3x3 const& A);
49   void set(vnl_matrix<double> const& A);
50 
51   void set(double a11, double a13, double a22, double a23, double a33);
52 
53   //: Return forward transformation matrix
get_C()54   vnl_double_3x3 get_C() const override { return A_; }
55 
56   //: Return inverse transformation matrix
get_C_inverse()57   vnl_double_3x3 get_C_inverse() const override { return A_inverse_; }
58 
59   //: Declare that this is a linear transformation
is_linear()60   bool is_linear() const override { return true; }
61 
62   //: Declare that this is not an isometry
can_invert_distance()63   bool can_invert_distance() const override { return false; }
64 
65   //: Send a human-readable representation to ostream
66   std::ostream& print(std::ostream& s) const override;
67 };
68 
69 #endif // AffineMetric_h_
70