HyperplaneCoordinateSystem.h
Go to the documentation of this file.
1 #ifndef __GfxTL_HYPERPLANECOORDINATESYSTEM_HEADER__
2 #define __GfxTL_HYPERPLANECOORDINATESYSTEM_HEADER__
3 #include <GfxTL/MathHelper.h>
4 #include <GfxTL/VectorXD.h>
5 
6 namespace GfxTL
7 {
8 
9  template <class Scalar, unsigned int D>
11  {
12  public:
13  enum
14  {
15  Dim = D,
16  HDim = Dim - 1
17  };
18  };
19 
20  template <class ScalarT>
21  class HyperplaneCoordinateSystem<ScalarT, 2>
22  {
23  public:
24  enum
25  {
26  Dim = 2,
27  HDim = Dim - 1
28  };
29 
30  typedef ScalarT ScalarType;
32 
33  template <class V>
34  void
35  FromNormal(const V& v)
36  {
37  m_axis[0][0] = -v[1];
38  m_axis[0][1] = v[0];
39  }
40 
41  PointType&
42  operator[](unsigned int i)
43  {
44  return m_axis[i];
45  }
46 
47  const PointType&
48  operator[](unsigned int i) const
49  {
50  return m_axis[i];
51  }
52 
53  private:
54  PointType m_axis[Dim - 1];
55  };
56 
57  template <class Scalar>
59  {
60  public:
61  enum
62  {
63  Dim = 3,
64  HDim = Dim - 1
65  };
66 
67  typedef Scalar ScalarType;
69 
71  {
72  for (unsigned int i = 0; i < Dim - 1; ++i)
73  {
74  _axis[i].Zero();
75  }
76  }
77 
79  {
80  FromNormal(PointType(x, y, z));
81  }
82 
83  template <class V>
85  {
86  FromNormal(n);
87  }
88 
89  void
91  {
92  FromNormal(PointType(x, y, z));
93  }
94 
95  template <class V>
96  void
97  FromNormal(const V& n)
98  {
99  FromNormal(PointType(n[0], n[1], n[2]));
100  }
101 
102  void
104  {
105  // perform arbitrary axis algorithm as
106  // specified by AutoCAD
107  if (Math<ScalarType>::Abs(n[0]) < ScalarType(0.015625f) &&
108  Math<ScalarType>::Abs(n[1]) < ScalarType(0.015625f))
109  {
110  _axis[0] = PointType(0, 1, 0) % n;
111  }
112  else
113  {
114  _axis[0] = PointType(0, 0, 1) % n;
115  }
116  _axis[0].Normalize();
117  _axis[1] = n % _axis[0];
118  _axis[1].Normalize();
119  }
120 
121  PointType&
122  operator[](unsigned int i)
123  {
124  return _axis[i];
125  }
126 
127  const PointType&
128  operator[](unsigned int i) const
129  {
130  return _axis[i];
131  }
132 
133  private:
134  PointType _axis[Dim - 1];
135  };
136 
137 }; // namespace GfxTL
138 
139 #endif
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::PointType
VectorXD< Dim, ScalarType > PointType
Definition: HyperplaneCoordinateSystem.h:68
GfxTL::HyperplaneCoordinateSystem
Definition: HyperplaneCoordinateSystem.h:10
GfxTL::VectorXD< Dim, ScalarType >
visionx::armem::pointcloud::PointType
PointType
Definition: constants.h:78
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::FromNormal
void FromNormal(ScalarType x, ScalarType y, ScalarType z)
Definition: HyperplaneCoordinateSystem.h:90
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::HyperplaneCoordinateSystem
HyperplaneCoordinateSystem(V n)
Definition: HyperplaneCoordinateSystem.h:84
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::ScalarType
Scalar ScalarType
Definition: HyperplaneCoordinateSystem.h:67
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::FromNormal
void FromNormal(const V &n)
Definition: HyperplaneCoordinateSystem.h:97
GfxTL::HyperplaneCoordinateSystem< ScalarT, 2 >::operator[]
PointType & operator[](unsigned int i)
Definition: HyperplaneCoordinateSystem.h:42
VectorXD.h
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::HyperplaneCoordinateSystem
HyperplaneCoordinateSystem(ScalarType x, ScalarType y, ScalarType z)
Definition: HyperplaneCoordinateSystem.h:78
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::operator[]
PointType & operator[](unsigned int i)
Definition: HyperplaneCoordinateSystem.h:122
GfxTL::Math
Definition: MathHelper.h:11
GfxTL
Definition: AABox.h:9
GfxTL::HyperplaneCoordinateSystem::Dim
@ Dim
Definition: HyperplaneCoordinateSystem.h:15
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::HyperplaneCoordinateSystem
HyperplaneCoordinateSystem()
Definition: HyperplaneCoordinateSystem.h:70
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::FromNormal
void FromNormal(const PointType &n)
Definition: HyperplaneCoordinateSystem.h:103
Scalar
float Scalar
Definition: basic.h:15
GfxTL::HyperplaneCoordinateSystem::HDim
@ HDim
Definition: HyperplaneCoordinateSystem.h:16
GfxTL::HyperplaneCoordinateSystem< ScalarT, 2 >::ScalarType
ScalarT ScalarType
Definition: HyperplaneCoordinateSystem.h:30
GfxTL::HyperplaneCoordinateSystem< ScalarT, 2 >::FromNormal
void FromNormal(const V &v)
Definition: HyperplaneCoordinateSystem.h:35
MathHelper.h
GfxTL::HyperplaneCoordinateSystem< ScalarT, 2 >::operator[]
const PointType & operator[](unsigned int i) const
Definition: HyperplaneCoordinateSystem.h:48
GfxTL::HyperplaneCoordinateSystem< Scalar, 3 >::operator[]
const PointType & operator[](unsigned int i) const
Definition: HyperplaneCoordinateSystem.h:128
GfxTL::HyperplaneCoordinateSystem< ScalarT, 2 >::PointType
VectorXD< Dim, ScalarType > PointType
Definition: HyperplaneCoordinateSystem.h:31