DGtal  1.5.beta
GAVector.h
1 
17 #pragma once
18 
28 #if defined(GAVector_RECURSES)
29 #error Recursive header files inclusion detected in GAVector.h
30 #else // defined(GAVector_RECURSES)
32 #define GAVector_RECURSES
33 
34 #if !defined GAVector_h
36 #define GAVector_h
37 
39 // Inclusions
40 #include "DGtal/base/Common.h"
41 #include "DGtal/kernel/BasicPointFunctors.h"
42 #include <DGtal/helpers/StdDefs.h>
43 #include <DGtal/kernel/domains/CDomain.h>
44 
45 namespace DGtal {
46  template<typename TSpace,typename TInputValue = typename TSpace::Point>
47  struct GAVector{
48  TInputValue my_gavec;
49 
51  explicit GAVector( const TInputValue& pt= TInputValue(0,0))
52  : my_gavec( pt ) {}
53 
55  typename TInputValue::Component dot( GAVector other ) const
56  {
57  return my_gavec[0] * other.my_gavec[0] + my_gavec[1] * other.my_gavec[1];
58  }
59 
61  typename TInputValue::Component bivectorPart( const GAVector& other ) const
62  {
63  return my_gavec[0] * other.my_gavec[1] - my_gavec[1] * other.my_gavec[0];
64  }
65 
67  GAVector operator*( typename TInputValue::Component f ) const
68  {
69  return GAVector( TInputValue(my_gavec[0] * f, my_gavec[1] * f) );
70  }
71 
73  GAVector operator*(const GAVector& v )// geometric product
74  {
75  return GAVector( TInputValue(this->dot(v), this->bivectorPart(v)) );
76  }
77  bool operator<( const GAVector& other ) const
78  {
79  return bivectorPart( other ) > 0;
80  }
81 
82  double angleToXAxis() const
83  {
84  return atan2( my_gavec[1], my_gavec[0] );
85  }
86 
87  bool operator==( const GAVector& other ) const
88  {
89  return bivectorPart( other ) == 0;
90  }
91 
92 
93  };
94 }
95 
96 #endif //GAVector
97 
98 #undef GAVector_RECURSES
99 #endif // else defined(GAVector_RECURSES)
DGtal is the top-level namespace which contains all DGtal functions and types.
TInputValue my_gavec
Definition: GAVector.h:48
TInputValue::Component bivectorPart(const GAVector &other) const
bivector part of the a mv, i.e. compute the outer product part of the geometric product
Definition: GAVector.h:61
bool operator<(const GAVector &other) const
Definition: GAVector.h:77
double angleToXAxis() const
Definition: GAVector.h:82
GAVector(const TInputValue &pt=TInputValue(0, 0))
zero multivector
Definition: GAVector.h:51
bool operator==(const GAVector &other) const
Definition: GAVector.h:87
TInputValue::Component dot(GAVector other) const
scalar part of the a mv, i.e. compute the dot product part of the geometric product
Definition: GAVector.h:55
GAVector operator*(const GAVector &v)
geometric product between two vectors
Definition: GAVector.h:73
GAVector operator*(typename TInputValue::Component f) const
geometric product with a scalar
Definition: GAVector.h:67