versor  3.0
C++11 library for Geometric algebra
vsr_conic.h
1 /*
2  * * =====================================================================================
3  *
4  * Filename: vsr_conic.h
5  *
6  * Description: conic transforms as described in Applications of Conformal Geometric Algebra
7  * in Computer Vision and Graphics, by wareham, cameron and j.lasenby
8  * see also Recent Applications of Conformal Geometric Algebra by a. lasenby
9  *
10  * Version: 1.0
11  * Created: 01/09/2014 12:44:21
12  * Revision: none
13  * Compiler: gcc
14  *
15  * Author: Pablo Colapinto (), wolftype (gmail)
16  * Organization: Media Arts and Technology Program, UCSB
17  *
18  * =====================================================================================
19  */
20 
23 #ifndef vsr_conic_INC
24 #define vsr_conic_INC
25 
26 
27 #include "detail/vsr_generic_op.h"
28 
29 
30 namespace vsr{
31 
48 class Conic {
49 
50  VSR_PRECISION ecc;
51 
52  public:
53 
63  template<class A>
64  static GAPnt<A> Transform( const GAVec<A> &vec, const GAVec<A>& v, VSR_PRECISION alpha){
65  VSR_PRECISION talpha = ( vec <= v)[0] * alpha;
66  GAPnt<A> p = vec.null();
67  GAPnt<A> p2 = p + GAOri<A>(1) * talpha; // * beta
68  auto wt = p2 <= GAInf<A>(1);
69  return Round::loc( p2 / -wt );
70  }
71 
81  template<class A>
82  static GAPnt<A> Transform( const GAPnt<A> & p, const GAVec<A>& v, VSR_PRECISION alpha){
83  VSR_PRECISION talpha = ( p <= v)[0] * alpha;
84  GAPnt<A> p2 = p + GAOri<A>(1) * talpha; // * beta
85  auto wt = p2 <= GAInf<A>(1);
86  return Round::loc( p2 / -wt );
87  }
88 
98  template<class A>
99  static GAPnt<A> ITransform(const GAPnt<A> & p, const GAVec<A>& v, VSR_PRECISION alpha){
100  VSR_PRECISION talpha = ( p <= v)[0] * alpha;
101  GAPnt<A> p2 = p - GAOri<A>(1) * talpha; // / beta
102  auto wt = p2 <= GAInf<A>(1);
103  return Round::loc( p2 / -wt );
104  }
114  template<class A>
115  static GALin<A> Transform( const GALin<A>& line, const GAVec<A>& v, VSR_PRECISION alpha){
116  GAPnt<A> pa = Flat::loc( line, PAO, false ).null();
117  GAPnt<A> tpa = Transform(pa,v,alpha);
118  GAPnt<A> pb = pa.trs( -Flat::dir( line ).template copy<GAVec<A>>().unit() );
119  GAPnt<A> tpb = Transform(pb,v,alpha);
120  return tpa ^ tpb ^ GAInf<A>(1);
121  }
122 
132  template<class A>
133  static GALin<A> ITransform( const GALin<A>& line, const GAVec<A>& v, VSR_PRECISION alpha){
134  GAPnt<A> pa = Flat::loc( line, PAO, false).null();
135  GAPnt<A> ipa = ITransform(pa,v,alpha);
136  GAPnt<A> pb = pa.trs( -Flat::dir( line ).template copy< GAVec<A> >().unit() );
137  GAPnt<A> ipb = ITransform(pb,v,alpha);
138  return ipa ^ ipb ^ GAInf<A>(1);
139  }
140 
142  template<class A>
143  static GADll<A> Transform( const GADll<A>& line, const GAVec<A>& v, VSR_PRECISION alpha){
144  GAPnt<A> pa = Flat::loc( line, PAO, true ).null();
145  GAPnt<A> tpa = Transform(pa,v,alpha);
146  GAPnt<A> pb = pa.trs( -Flat::dir( line.dual() ).template copy<GAVec<A>>().unit() );
147  GAPnt<A> tpb = Transform(pb,v,alpha);
148  return (tpa ^ tpb ^ GAInf<A>(1)).dual();
149  }
150 
152  template<class A>
153  static GADll<A> ITransform( const GADll<A>& line, const GAVec<A>& v, VSR_PRECISION alpha){
154  GAPnt<A> pa = Flat::loc( line, PAO, true).null();
155  GAPnt<A> ipa = ITransform(pa,v,alpha);
156  GAPnt<A> pb = pa.trs( -Flat::dir( line.dual() ).template copy< GAVec<A> >().unit() );
157  GAPnt<A> ipb = ITransform(pb,v,alpha);
158  return (ipa ^ ipb ^ GAInf<A>(1)).dual();
159  }
160 
162  template<class A>
163  static GAPln<A> Transform( const GAPln<A>& plane, const GAVec<A>& v, VSR_PRECISION alpha){
164  //get points to apply aipoint to
165  GAPnt<A> pa = Flat::loc( plane, PAO, false ).null();
166  auto ca = ( Round::dls(pa, 1) ^ plane.dual() ).dual();
167  auto pb = Round::pnt_cir(ca, 0);
168  auto pc = Round::pnt_cir(ca, PIOVERFOUR);
169 
170  GAPnt<A> tpa = Transform(pa,v,alpha);
171  GAPnt<A> tpb = Transform(pb,v,alpha);
172  GAPnt<A> tpc = Transform(pc,v,alpha);
173  return tpa ^ tpb ^ tpc ^ GAInf<A>(1);
174  }
175 
177  template<class A>
178  static GAPln<A> ITransform( const GAPln<A>& plane, const GAVec<A>& v, VSR_PRECISION alpha){
179  //get points to apply aipoint to
180  GAPnt<A> pa = Flat::loc( plane, PAO, false ).null();
181  auto ca = ( Round::dls(pa, 1) ^ plane.dual() ).dual();
182  auto pb = Round::pnt_cir(ca, 0);
183  auto pc = Round::pnt_cir(ca, PIOVERFOUR);
184 
185  GAPnt<A> tpa = ITransform(pa,v,alpha);
186  GAPnt<A> tpb = ITransform(pb,v,alpha);
187  GAPnt<A> tpc = ITransform(pc,v,alpha);
188  return tpa ^ tpb ^ tpc ^ GAInf<A>(1);
189  }
190 
192  template<class A>
193  static GADlp<A> Transform( const GADlp<A>& plane, const GAVec<A>& v, VSR_PRECISION alpha){
194  GAPnt<A> pa = Flat::loc( plane, PAO, true).null();
195  auto ca = ( Round::dls(pa, 1) ^ plane ).dual();
196  auto pb = Round::pnt_cir(ca, 0);
197  auto pc = Round::pnt_cir(ca, PIOVERFOUR);
198 
199  GAPnt<A> ipa = Transform(pa,v,alpha);
200  GAPnt<A> ipb = Transform(pb,v,alpha);
201  GAPnt<A> ipc = Transform(pc,v,alpha);
202 
203  return (ipa ^ ipb ^ ipc ^ GAInf<A>(1)).dual();
204  }
205 
207  template<class A>
208  static GADlp<A> ITransform( const GADlp<A>& plane, const GAVec<A>& v, VSR_PRECISION alpha){
209  GAPnt<A> pa = Flat::loc( plane, PAO, true).null();
210  auto ca = ( Round::dls(pa, 1) ^ plane ).dual();
211  auto pb = Round::pnt_cir(ca, 0);
212  auto pc = Round::pnt_cir(ca, PIOVERFOUR);
213 
214  GAPnt<A> ipa = ITransform(pa,v,alpha);
215  GAPnt<A> ipb = ITransform(pb,v,alpha);
216  GAPnt<A> ipc = ITransform(pc,v,alpha);
217 
218  return (ipa ^ ipb ^ ipc ^ GAInf<A>(1) ).dual();
219  }
220 
221 
222  /* template<class A> */
223  /* static GADlp<A> Transform( const GADlp<A>& plane, const GAVec<A>& v, VSR_PRECISION alpha){ */
224  /* //get points to apply aipoint to */
225  /* GAPnt<A> pa = Flat::loc( plane, PAO, true ).null(); */
226  /* GAPnt<A> tpa = Transform(pa,v,alpha); */
227  /* GAPnt<A> pb = pa.trs( -Flat::dir( plane.dual() ).dual().template copy<GAVec<A>>().unit() );//normal */
228  /* GAPnt<A> tpb = Vec( Transform(pb,v,alpha) ).unit(); */
229  /* return tpa <= tpb.template copy<NDrv<DIM>>(); */
230  /* } */
231 
232  /* template<class A> */
233  /* static GADlp<A> ITransform( const GADlp<A>& plane, const GAVec<A>& v, VSR_PRECISION alpha){ */
234  /* GAPnt<A> pa = Flat::loc( plane, PAO, true).null(); */
235  /* GAPnt<A> ipa = ITransform(pa,v,alpha); */
236  /* GAPnt<A> pb = pa.trs( -Flat::dir( plane.dual() ).dual().template copy< GAVec<A> >().unit() ); */
237  /* GAPnt<A> ipb = Vec( ITransform(pb,v,alpha) - ipa ).unit(); */
238  /* return ipa <= ipb.template copy<NDrv<DIM>>(); */
239  /* } */
240 
241 
242 };
243 
244 
245 } //vsr::
246 
247 #endif /* ----- #ifndef vsr_conic_INC ----- */
248 
conic transforms
Definition: vsr_conic.h:48
static GAPnt< A > ITransform(const GAPnt< A > &p, const GAVec< A > &v, VSR_PRECISION alpha)
Inverse Transform of a vsr::cga::Point.
Definition: vsr_conic.h:99
static GAPnt< A > Transform(const GAPnt< A > &p, const GAVec< A > &v, VSR_PRECISION alpha)
Transform a vsr::cga::Point.
Definition: vsr_conic.h:82
static GADll< A > Transform(const GADll< A > &line, const GAVec< A > &v, VSR_PRECISION alpha)
Transform a dual line in direction v with eccentricity alpha.
Definition: vsr_conic.h:143
static GALin< A > Transform(const GALin< A > &line, const GAVec< A > &v, VSR_PRECISION alpha)
Transform a vsr::cga::Point.
Definition: vsr_conic.h:115
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
Multivector< algebra, typename algebra::vector_basis > null() const
Conformal Mapping \(\boldsymbol(x)\to n_o + \boldsymbol{x} + \boldsymbol{x}^2n_\infty \) ...
Definition: vsr_generic_op.h:1118
static GADlp< A > Transform(const GADlp< A > &plane, const GAVec< A > &v, VSR_PRECISION alpha)
Transform a dual plane in direction v with eccentricity alpha.
Definition: vsr_conic.h:193
#define PAO
vsr::cga::Point At Origin
Definition: vsr_cga3D_op.h:634
static GAPln< A > ITransform(const GAPln< A > &plane, const GAVec< A > &v, VSR_PRECISION alpha)
Inverse Transform a plane in direction v with eccentricity alpha.
Definition: vsr_conic.h:178
core namespaced operations that are metric-agnostic
static GADlp< A > ITransform(const GADlp< A > &plane, const GAVec< A > &v, VSR_PRECISION alpha)
Inverse Transform a dual plane in direction v with eccentricity alpha.
Definition: vsr_conic.h:208
static GADll< A > ITransform(const GADll< A > &line, const GAVec< A > &v, VSR_PRECISION alpha)
Inverse Transform a dual line in direction v with eccentricity alpha.
Definition: vsr_conic.h:153
the versor library namespace
Definition: vsr_algebra.h:29
static GALin< A > ITransform(const GALin< A > &line, const GAVec< A > &v, VSR_PRECISION alpha)
Transform a vsr::cga::Point.
Definition: vsr_conic.h:133
static GAPln< A > Transform(const GAPln< A > &plane, const GAVec< A > &v, VSR_PRECISION alpha)
Transform a plane in direction v with eccentricity alpha.
Definition: vsr_conic.h:163
static GAPnt< A > Transform(const GAVec< A > &vec, const GAVec< A > &v, VSR_PRECISION alpha)
Transform a vsr::cga::Vec.
Definition: vsr_conic.h:64