CustusX  22.04-rc2
An IGT application
plane3d.hpp
Go to the documentation of this file.
1 #ifndef PLANE3D_HPP
2 #define PLANE3D_HPP
3 #include <Eigen/Dense>
4 
5 //#define DEBUG_PLANE
6 
7 
11 class Plane3D
12 {
13 public:
14 
19  Plane3D(const double coeffs[4])
20  {
21  for(int i = 0; i < 4; i++)
22  {
23  m_coeffs[i] = coeffs[i];
24  }
25  }
26 
31  Plane3D(const Eigen::Matrix4f coeffs)
32  {
33  for(int i = 0; i < 3; i++)
34  {
35  m_coeffs[i] = coeffs(i,2);
36  }
37  m_coeffs[3] = 0.0;
38  for(int i = 0; i < 3; i++)
39  {
40 
41  m_coeffs[3] -= m_coeffs[i]*coeffs(i,3);
42  }
43  }
44 
49  Plane3D(const Eigen::Matrix4d coeffs)
50  {
51  for(int i = 0; i < 3; i++)
52  {
53  m_coeffs[i] = coeffs(i,2);
54  }
55  m_coeffs[3] = 0.0;
56  for(int i = 0; i < 3; i++)
57  {
58 
59  m_coeffs[3] -= m_coeffs[i]*coeffs(i,3);
60  }
61  }
62 
67  {
68  for(int i = 0; i < 4; i++)
69  {
70  m_coeffs[i] = 0.0;
71  }
72  };
73  ~Plane3D() { }
74 
80  inline void setCoefficient(const int i, const double c)
81  {
82  m_coeffs[i] = c;
83  }
89  inline double getCoefficient(const int i)
90  {
91  return m_coeffs[i];
92  }
98  inline double getDistance(double const pt[3]) const
99  {
100  double ret = 0.0;
101  for(int i = 0; i < 3; i++)
102  {
103  ret += pt[i]*m_coeffs[i];
104  }
105  ret += m_coeffs[3];
106 #ifdef DEBUG_PLANE
107  cerr << "Distance: " << ret << endl;
108 #endif
109  return ret;
110  }
111 
117  // void projectOnto(double projected[3], double const pt[3] ) const; DELETED
118 
119 protected:
123  double m_coeffs[4];
124 
125 };
126 
127 #endif // PLANE3D_HPP
void setCoefficient(const int i, const double c)
Definition: plane3d.hpp:80
double m_coeffs[4]
Definition: plane3d.hpp:123
Plane3D(const Eigen::Matrix4f coeffs)
Definition: plane3d.hpp:31
Plane3D(const Eigen::Matrix4d coeffs)
Definition: plane3d.hpp:49
~Plane3D()
Definition: plane3d.hpp:73
Plane3D()
Definition: plane3d.hpp:66
double getCoefficient(const int i)
Definition: plane3d.hpp:89
Plane3D(const double coeffs[4])
Definition: plane3d.hpp:19
double getDistance(double const pt[3]) const
Definition: plane3d.hpp:98