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,class E1>
31  void set(const E0& e0,const E1& e1)
32  {
33  _m = e0.get_mat() * e1.get_mat();
34  _inv_m = invert(_m);
35  }
37  template <class E0,class E1,class E2>
38  void set(const E0& e0,const E1& e1,const E2& e2)
39  {
40  _m = e0.get_mat() * e1.get_mat() * e2.get_mat();
41  _inv_m = invert(_m);
42  }
44  template <class E0,class E1,class E2,class E3>
45  void set(const E0& e0,const E1& e1,const E2& e2,const E3& e3)
46  {
47  _m = e0.get_mat() * e1.get_mat() * e2.get_mat() * e3.get_mat();
48  _inv_m = invert(_m);
49  }
51  vec2_type eval(const vec2_type& p) const
52  { return _m * p; }
54  vec2_type eval_inv(const vec2_type& q) const
55  { return _inv_m * q; }
57  vec2_type eval_inv(const vec2_type& q,const vec2_type& p_start) const
58  { return _inv_m * q; }
60  const mat2_type& get_mat() const
61  { return _m; }
63  const mat2_type& get_mat_inv() const
64  { return _inv_m; }
65  };
66  }
void set(const E0 &e0, const E1 &e1, const E2 &e2)
Building the matrix from three extenders. Order is m(E0) * m(E1) * m(E2).
Definition: ldpk_linear_extender.h:38
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:51
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_linear_extender.h:63
void set(const mat2_type &m)
Passing the matrix.
Definition: ldpk_linear_extender.h:24
void set(const E0 &e0, const E1 &e1, const E2 &e2, const E3 &e3)
Building the matrix from four extenders. Order is m(E0) * m(E1) * m(E2) * m(E3).
Definition: ldpk_linear_extender.h:45
const mat2_type & get_mat() const
The matrix for this extender.
Definition: ldpk_linear_extender.h:60
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:57
void set(const E0 &e0, const E1 &e1)
Building the matrix from two extenders. Order is m(E0) * m(E1).
Definition: ldpk_linear_extender.h:31
vec2_type eval_inv(const vec2_type &q) const
eval_inv() is applying lens distortion (distort)
Definition: ldpk_linear_extender.h:54
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