ldpk
ldpk_cylindric_extender.h
1 #ifndef ldpk_cylindric_extender_sdv
2 #define ldpk_cylindric_extender_sdv
3 
4 #include <ldpk/ldpk_extender_base.h>
5 
6 namespace ldpk
7  {
8  template <class VEC2,class MAT2>
9  class cylindric_extender:public extender_base<VEC2,MAT2>
10  {
11  public:
12  typedef VEC2 vec2_type;
13  typedef MAT2 mat2_type;
14  private:
15  double _phi,_b;
16  mat2_type _m,_inv_m;
17 
18  void calc_m()
19  {
20  mat2_type para = tensq(vec2_type(cos(_phi * M_PI / 180.0),sin(_phi * M_PI / 180.0)));
21  _m = _b * para + mat2_type(1.0);
22  _inv_m = invert(_m);
23  }
24  public:
26  {
27  _phi = 0.0;
28  _b = 0.0;
29  _m = mat2_type(1.0);
30  _inv_m = mat2_type(1.0);
31  }
33  void set_phi(double phi)
34  { _phi = phi;calc_m(); }
35  double get_phi() const
36  { return _phi; }
38  void set_b(double b)
39  { _b = b;calc_m(); }
40  double get_b() const
41  { return _b; }
43  vec2_type eval(const vec2_type& p) const
44  { return _m * p; }
46  vec2_type eval_inv(const vec2_type& q) const
47  { return _inv_m * q; }
49  vec2_type eval_inv(const vec2_type& q,const vec2_type& p_start) const
50  { return _inv_m * q; }
52  const mat2_type& get_mat() const
53  { return _m; }
55  const mat2_type& get_mat_inv() const
56  { return _inv_m; }
57  };
58 
64  template <class VEC2,class MAT2>
65  class cylindric_extender_2:public extender_base<VEC2,MAT2>
66  {
67  public:
68  typedef VEC2 vec2_type;
69  typedef MAT2 mat2_type;
70  private:
71  double _phi,_b;
72  mat2_type _m,_inv_m;
73 
74  void calc_m()
75  {
76  double q = sqrt(1.0 + _b),c = cos(_phi * M_PI / 180.0),s = sin(_phi * M_PI / 180.0);
77  _m = mat2_type(c*c*q + s*s/q,(q - 1.0/q)*c*s,(q - 1.0/q)*c*s,c*c/q + s*s*q);
78  _inv_m = invert(_m);
79  }
80  public:
82  {
83  _phi = 0.0;
84  _b = 0.0;
85  _m = mat2_type(1.0);
86  _inv_m = mat2_type(1.0);
87  }
89  void set_phi(double phi)
90  { _phi = phi;calc_m(); }
91  double get_phi() const
92  { return _phi; }
94  void set_b(double b)
95  { _b = b;calc_m(); }
96  double get_b() const
97  { return _b; }
99  vec2_type eval(const vec2_type& p) const
100  { return _m * p; }
102  virtual vec2_type eval_inv(const vec2_type& q) const
103  { return _inv_m * q; }
105  vec2_type eval_inv(const vec2_type& q,const vec2_type& p_start) const
106  { return _inv_m * q; }
108  const mat2_type& get_mat() const
109  { return _m; }
111  const mat2_type& get_mat_inv() const
112  { return _inv_m; }
113  };
114  }
115 
116 #endif
mat2d tensq(const vec2d &a)
Tensor (dyadic) product square.
Definition: ldpk_vec2d.h:186
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
virtual vec2_type eval_inv(const vec2_type &q) const
eval_inv() is applying lens distortion (distort)
Definition: ldpk_cylindric_extender.h:102
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_cylindric_extender.h:111
Definition: ldpk_cylindric_extender.h:9
vec2_type eval_inv(const vec2_type &q) const
eval_inv() is applying lens distortion (distort)
Definition: ldpk_cylindric_extender.h:46
const mat2_type & get_mat() const
The matrix for this extender.
Definition: ldpk_cylindric_extender.h:52
The namespace of (most of the) things related to the Lens Distortion Plugin Kit.
Definition: ldpk.h:169
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_cylindric_extender.h:49
void set_b(double b)
This parameter expresses the strength of the cylindric deformation ("bending").
Definition: ldpk_cylindric_extender.h:94
void set_b(double b)
This parameter expresses the strength of the cylindric deformation ("bending").
Definition: ldpk_cylindric_extender.h:38
void set_phi(double phi)
The cylindric extender has a parameter called phi.
Definition: ldpk_cylindric_extender.h:33
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_cylindric_extender.h:105
"Symmetric" version. Scaling by sqrt(1+b) in para-direction and 1/sqrt(1+b) in ortho-direction. The important thing is, that we have turned an almost-symmetry into a perfect symmetry: phi -> phi + 90deg, b -> 1/b. The drawback is, that this models the curved beam splitter only if focal length is corrected slightly, by a factor sqrt(1+b). Nevertheless we are using this model in "3DE4 Radial - Standard, Degree 4".
Definition: ldpk_cylindric_extender.h:65
const mat2_type & get_mat() const
The matrix for this extender.
Definition: ldpk_cylindric_extender.h:108
vec2_type eval(const vec2_type &p) const
eval() is per definition removal of lens distortion (undistort).
Definition: ldpk_cylindric_extender.h:99
void set_phi(double phi)
The cylindric extender has a parameter called phi.
Definition: ldpk_cylindric_extender.h:89
vec2_type eval(const vec2_type &p) const
eval() is per definition removal of lens distortion (undistort).
Definition: ldpk_cylindric_extender.h:43
const mat2_type & get_mat_inv() const
The inverse matrix for this extender.
Definition: ldpk_cylindric_extender.h:55