VectorKernel.h
Go to the documentation of this file.
1 #ifndef GfxTL__VECTORKERNEL_HEADER__
2 #define GfxTL__VECTORKERNEL_HEADER__
3 
4 #include <GfxTL/NullClass.h>
7 #include <GfxTL/VectorXD.h>
8 
9 namespace GfxTL
10 {
12  {
13  public:
14  void
15  Dimension(unsigned int dim)
16  {
17  m_dim = dim;
18  }
19 
20  const unsigned int
21  Dimension() const
22  {
23  return m_dim;
24  }
25 
26  protected:
27  unsigned int m_dim;
28  };
29 
30  template <unsigned int DimT>
32  {
33  public:
34  const unsigned int
35  Dimension() const
36  {
37  return m_dim;
38  }
39 
40  protected:
41  enum
42  {
43  m_dim = DimT
44  };
45  };
46 
47  template <class DimensionStrategyT, class BaseT = NullClass>
48  struct VectorKernel : public BaseT, public DimensionStrategyT
49  {
50  typedef DimensionStrategyT DimensionStrategyType;
51 
52  template <class PointAT, class PointBT>
53  void
54  AssignVector(const PointAT& a, const PointBT* b) const
55  {
56  for (unsigned int i = 0; i < DimensionStrategyT::m_dim; ++i)
57  {
58  (*b)[i] = a[i];
59  }
60  }
61 
62  template <class PointAT, class PointBT, class PointDT>
63  void
64  Add(const PointAT& a, const PointBT& b, PointDT* d) const
65  {
66  for (unsigned int i = 0; i < DimensionStrategyT::m_dim; ++i)
67  {
68  (*d)[i] = a[i] + b[i];
69  }
70  }
71 
72  template <class PointAT, class PointBT, class PointDT>
73  void
74  Sub(const PointAT& a, const PointBT& b, PointDT* d) const
75  {
76  for (unsigned int i = 0; i < DimensionStrategyT::m_dim; ++i)
77  {
78  (*d)[i] = a[i] - b[i];
79  }
80  }
81 
82  template <class PointAT, class PointBT>
83  typename ScalarTypeConversion<
84  typename ScalarTypeConversion<
86  typename ScalarTypeDeferer<PointBT>::ScalarType>::MultiplicationType,
87  typename ScalarTypeConversion<
89  typename ScalarTypeDeferer<PointBT>::ScalarType>::MultiplicationType>::AdditionType
90  Dot(const PointAT& a, const PointBT& b) const
91  {
92  typename ScalarTypeConversion<
93  typename ScalarTypeConversion<
95  typename ScalarTypeDeferer<PointBT>::ScalarType>::MultiplicationType,
98  MultiplicationType>::AdditionType d = a[0] * b[0];
99  for (unsigned int i = 1; i < DimensionStrategyT::m_dim; ++i)
100  {
101  d += a[i] * b[i];
102  }
103  return d;
104  }
105 
106  template <class PointAT, class PointBT>
107  void
108  Mul(typename ScalarTypeDeferer<PointAT>::ScalarType s, const PointAT& a, PointBT* b) const
109  {
110  for (unsigned int i = 0; i < DimensionStrategyT::m_dim; ++i)
111  {
112  (*b)[i] = s * a[i];
113  }
114  }
115  };
116 
117  template <class BaseT = NullClass>
118  struct DynVectorKernel : public VectorKernel<DynamicDimensionVectorKernelStrategy, BaseT>
119  {
120  };
121 
122  template <unsigned int DimT>
124  {
125  template <class BaseT = NullClass>
127  public VectorKernel<FixedDimensionVectorKernelStrategy<DimT>, BaseT>
128  {
129  };
130  };
131 }; // namespace GfxTL
132 
133 #endif
GfxTL::VectorKernel::Add
void Add(const PointAT &a, const PointBT &b, PointDT *d) const
Definition: VectorKernel.h:64
GfxTL::VectorKernelD
Definition: VectorKernel.h:123
GfxTL::DynamicDimensionVectorKernelStrategy::Dimension
void Dimension(unsigned int dim)
Definition: VectorKernel.h:15
GfxTL::DynamicDimensionVectorKernelStrategy
Definition: VectorKernel.h:11
GfxTL::ScalarTypeDeferer::ScalarType
PointT::value_type ScalarType
Definition: ScalarTypeDeferer.h:15
GfxTL::VectorKernelD::VectorKernelType
Definition: VectorKernel.h:126
GfxTL::VectorKernel::Dot
ScalarTypeConversion< typename ScalarTypeConversion< typename ScalarTypeDeferer< PointAT >::ScalarType, typename ScalarTypeDeferer< PointBT >::ScalarType >::MultiplicationType, typename ScalarTypeConversion< typename ScalarTypeDeferer< PointAT >::ScalarType, typename ScalarTypeDeferer< PointBT >::ScalarType >::MultiplicationType >::AdditionType Dot(const PointAT &a, const PointBT &b) const
Definition: VectorKernel.h:90
GfxTL::FixedDimensionVectorKernelStrategy::Dimension
const unsigned int Dimension() const
Definition: VectorKernel.h:35
ScalarTypeConversion.h
VectorXD.h
GfxTL::DynamicDimensionVectorKernelStrategy::m_dim
unsigned int m_dim
Definition: VectorKernel.h:27
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
GfxTL::VectorKernel::Sub
void Sub(const PointAT &a, const PointBT &b, PointDT *d) const
Definition: VectorKernel.h:74
GfxTL::VectorKernel::DimensionStrategyType
DimensionStrategyT DimensionStrategyType
Definition: VectorKernel.h:50
GfxTL::DynamicDimensionVectorKernelStrategy::Dimension
const unsigned int Dimension() const
Definition: VectorKernel.h:21
GfxTL
Definition: AABox.h:9
GfxTL::ScalarTypeConversion
Definition: ScalarTypeConversion.h:7
NullClass.h
GfxTL::VectorKernel::AssignVector
void AssignVector(const PointAT &a, const PointBT *b) const
Definition: VectorKernel.h:54
GfxTL::VectorKernel
Definition: VectorKernel.h:48
GfxTL::VectorKernel::Mul
void Mul(typename ScalarTypeDeferer< PointAT >::ScalarType s, const PointAT &a, PointBT *b) const
Definition: VectorKernel.h:108
GfxTL::FixedDimensionVectorKernelStrategy::m_dim
@ m_dim
Definition: VectorKernel.h:43
ScalarTypeDeferer.h
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
GfxTL::FixedDimensionVectorKernelStrategy
Definition: VectorKernel.h:31