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