ldpk
ldpk_squeeze_extender.h
1 #ifndef ldpk_squeeze_xy_extender_sdv
2 #define ldpk_squeeze_xy_extender_sdv
3 
4 #include <ldpk/ldpk_extender_base.h>
5 
6 namespace ldpk
7  {
10  template <class VEC2,class MAT2>
11  class squeeze_x_extender:public extender_base<VEC2,MAT2>
12  {
13  public:
14  typedef VEC2 vec2_type;
15  typedef MAT2 mat2_type;
16  private:
17  double _sq;
18  mat2_type _m_sq,_inv_m_sq;
19 
20  public:
22  {
23  _sq = 1.0;
24  _m_sq = mat2_type(1.0);
25  _inv_m_sq = mat2_type(1.0);
26  }
27 // The squeeze extender has one parameter called sq.
28  void set_sq(double sq)
29  {
30  _sq = sq;
31  _m_sq = mat2_type(_sq,0.0,0.0,1.0);
32  _inv_m_sq = mat2_type(1.0 / _sq,0.0,0.0,1.0);
33  }
34  double get_sq() const
35  { return _sq; }
36 
38  vec2_type eval(const vec2_type& p) const
39  { return _m_sq * p; }
41  vec2_type eval_inv(const vec2_type& q) const
42  { return _inv_m_sq * q; }
44  vec2_type eval_inv(const vec2_type& q,const vec2_type& p_start) const
45  { return _inv_m_sq * q; }
47  const mat2_type& get_mat() const
48  { return _m_sq; }
50  const mat2_type& get_mat_inv() const
51  { return _inv_m_sq; }
52  };
53  template <class VEC2,class MAT2>
54  class squeeze_y_extender:public extender_base<VEC2,MAT2>
55  {
56  public:
57  typedef VEC2 vec2_type;
58  typedef MAT2 mat2_type;
59  private:
60  double _sq;
61  mat2_type _m_sq,_inv_m_sq;
62 
63  public:
65  {
66  _sq = 1.0;
67  _m_sq = mat2_type(1.0);
68  _inv_m_sq = mat2_type(1.0);
69  }
70 // The squeeze extender has one parameter called sq.
71  void set_sq(double sq)
72  {
73  _sq = sq;
74  _m_sq = mat2_type(1.0,0.0,0.0,_sq);
75  _inv_m_sq = mat2_type(1.0,0.0,0.0,1.0 / _sq);
76  }
77  double get_sq() const
78  { return _sq; }
79 
81  vec2_type eval(const vec2_type& p) const
82  { return _m_sq * p; }
84  vec2_type eval_inv(const vec2_type& q) const
85  { return _inv_m_sq * q; }
87  vec2_type eval_inv(const vec2_type& q,const vec2_type& p_start) const
88  { return _inv_m_sq * q; }
90  const mat2_type& get_mat() const
91  { return _m_sq; }
93  const mat2_type& get_mat_inv() const
94  { return _inv_m_sq; }
95  };
96  }
97 
98 #endif
const mat2_type & get_mat() const
The matrix for this extender.
Definition: ldpk_squeeze_extender.h:90
vec2_type eval_inv(const vec2_type &q) const
eval_inv() is applying lens distortion (distort)
Definition: ldpk_squeeze_extender.h:41
Base class of all extenders The concept of extenders as turned out to be useful in the new-style dist...
Definition: ldpk_extender_base.h:16
const mat2_type & get_mat() const
The matrix for this extender.
Definition: ldpk_squeeze_extender.h:47
vec2_type eval_inv(const vec2_type &q, const vec2_type &p_start) const
Generally (but not here), an initial value is needed for calculating the inverse. ...
Definition: ldpk_squeeze_extender.h:44
The squeeze-x/y-extender scales the optical-axis-perpendicular coordinates of the incident ray toward...
Definition: ldpk_squeeze_extender.h:11
Definition: ldpk_squeeze_extender.h:54
vec2_type eval_inv(const vec2_type &q) const
eval_inv() is applying lens distortion (distort)
Definition: ldpk_squeeze_extender.h:84
The namespace of (most of the) things related to the Lens Distortion Plugin Kit.
Definition: ldpk.h:180
vec2_type eval_inv(const vec2_type &q, const vec2_type &p_start) const
Generally (but not here), an initial value is needed for calculating the inverse. ...
Definition: ldpk_squeeze_extender.h:87
vec2_type eval(const vec2_type &p) const
eval() is per definition removal of lens distortion (undistort).
Definition: ldpk_squeeze_extender.h:38
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_squeeze_extender.h:93
vec2_type eval(const vec2_type &p) const
eval() is per definition removal of lens distortion (undistort).
Definition: ldpk_squeeze_extender.h:81
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_squeeze_extender.h:50