ldpk
ldpk_linear_extender.h
1 #pragma once
2 
3 #include <ldpk/ldpk_extender_base.h>
4 
5 namespace ldpk
6  {
8  template <class VEC2,class MAT2>
9  class linear_extender:public extender_base<VEC2,MAT2>
10  {
11  public:
12  typedef VEC2 vec2_type;
13  typedef MAT2 mat2_type;
14  private:
15  mat2_type _m,_inv_m;
16  public:
19  {
20  _m = mat2_type(1.0);
21  _inv_m = mat2_type(1.0);
22  }
24  void set(const mat2_type& m)
25  {
26  _m = m;
27  _inv_m = invert(_m);
28  }
30  template <class E0>
31  void set(const E0& e0)
32  {
33  _m = e0.get_mat();
34  _inv_m = invert(_m);
35  }
37  template <class E0,class E1>
38  void set(const E0& e0,const E1& e1)
39  {
40  _m = e0.get_mat() * e1.get_mat();
41  _inv_m = invert(_m);
42  }
44  template <class E0,class E1,class E2>
45  void set(const E0& e0,const E1& e1,const E2& e2)
46  {
47  _m = e0.get_mat() * e1.get_mat() * e2.get_mat();
48  _inv_m = invert(_m);
49  }
51  template <class E0,class E1,class E2,class E3>
52  void set(const E0& e0,const E1& e1,const E2& e2,const E3& e3)
53  {
54  _m = e0.get_mat() * e1.get_mat() * e2.get_mat() * e3.get_mat();
55  _inv_m = invert(_m);
56  }
58  template <class E0,class E1,class E2,class E3,class E4>
59  void set(const E0& e0,const E1& e1,const E2& e2,const E3& e3,const E4& e4)
60  {
61  _m = e0.get_mat() * e1.get_mat() * e2.get_mat() * e3.get_mat() * e4.get_mat();
62  _inv_m = invert(_m);
63  }
65  vec2_type eval(const vec2_type& p) const
66  { return _m * p; }
68  vec2_type eval_inv(const vec2_type& q) const
69  { return _inv_m * q; }
71  vec2_type eval_inv(const vec2_type& q,const vec2_type& p_start) const
72  { return _inv_m * q; }
74  const mat2_type& get_mat() const
75  { return _m; }
77  const mat2_type& get_mat_inv() const
78  { return _inv_m; }
79  };
80  }
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
vec2_type eval(const vec2_type &p) const
eval() is per definition removal of lens distortion (undistort).
Definition: ldpk_linear_extender.h:65
The namespace of (most of the) things related to the Lens Distortion Plugin Kit.
Definition: ldpk.h:19
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_linear_extender.h:77
const mat2_type & get_mat() const
The matrix for this extender.
Definition: ldpk_linear_extender.h:74
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_linear_extender.h:71
vec2_type eval_inv(const vec2_type &q) const
eval_inv() is applying lens distortion (distort)
Definition: ldpk_linear_extender.h:68
A general linear extender, based on a 2x2-matrix.
Definition: ldpk_linear_extender.h:9
linear_extender()
Default: unit matrix.
Definition: ldpk_linear_extender.h:18