homogeneous_point.hpp
Go to the documentation of this file.
1 
11 /*****************************************************************************
12 ** Ifdefs
13 *****************************************************************************/
14 
15 #ifndef ECL_GEOMETRY_HOMOGENEOUS_POINT_HPP_
16 #define ECL_GEOMETRY_HOMOGENEOUS_POINT_HPP_
17 
18 /*****************************************************************************
19 ** Includes
20 *****************************************************************************/
21 
22 #include <ecl/mpl.hpp>
23 #include <ecl/type_traits.hpp>
24 
25 #include <ecl/config/macros.hpp>
27 #include <ecl/linear_algebra.hpp>
28 #include <ecl/math.hpp>
29 
30 /*****************************************************************************
31 ** Namespaces
32 *****************************************************************************/
33 
34 namespace ecl {
35 
36 /*****************************************************************************
37 ** Interface [HomogeneousPoint]
38 *****************************************************************************/
45 template <typename T, typename Enable = void>
47 
55 template<typename T>
56 class HomogeneousPoint<T, typename ecl::enable_if< ecl::is_float<T> >::type> {
57 public:
58  EIGEN_MAKE_ALIGNED_OPERATOR_NEW // needed for 16B alignment
62  HomogeneousPoint(const T &value = T()) {
63  elements.template block<3,1>(0,0) = ecl::linear_algebra::Matrix<T,3,1>::Constant(value);
64  elements(3,0) = 1.0;
65  }
74  HomogeneousPoint(const ecl::linear_algebra::Matrix<T,3,1> &vec) {
75  elements.template block<3,1>(0,0) = vec;
76  elements[3] = 1.0;
77  }
85  HomogeneousPoint(const ecl::linear_algebra::Matrix<T,4,1> &vec) : elements(vec) {
87  }
95  HomogeneousPoint(const T &x_i, const T &y_i, const T &z_i) {
96  elements << x_i, y_i, z_i, 1.0;
97  }
98 
99  virtual ~HomogeneousPoint() {}
100 
101  /*********************
102  ** Assignment
103  **********************/
117  ecl::linear_algebra::CommaInitializer< ecl::linear_algebra::Matrix<T,4,1> > operator<<(const T &value) {
118  return elements.operator<<(value);
119  }
120 
128  ecl::linear_algebra::Matrix<T,4,1>& positionVector() { return elements; }
129 
137  const ecl::linear_algebra::Matrix<T,4,1>& positionVector() const { return elements; }
138 
144  const T& x() const { return elements[0]; }
150  const T& y() const { return elements[1]; }
156  const T& z() const { return elements[2]; }
162  T x() { return elements[0]; }
168  T y() { return elements[1]; }
174  T z() { return elements[2]; }
175 
176  void x(const T& value) { elements[0] = value; }
177  void y(const T& value) { elements[1] = value; }
178  void z(const T& value) { elements[2] = value; }
180  template <typename OutputStream, typename Type>
181  friend OutputStream& operator<<(OutputStream &ostream , const HomogeneousPoint<Type> &point);
182 
183 private:
184  ecl::linear_algebra::Matrix<T,4,1> elements;
185 };
186 
190 /*********************
191 ** Streaming
192 **********************/
200 template <typename OutputStream, typename Type>
201 OutputStream& operator<<(OutputStream &ostream , const HomogeneousPoint<Type> &point) {
202  ostream << "[ " << point.x() << " " << point.y() << " " << point.z() << " ]";
203  return ostream;
204 }
205 } // namespace ecl
206 
207 #endif /* ECL_GEOMETRY_HOMOGENEOUS_POINT_HPP_ */
EIGEN_MAKE_ALIGNED_OPERATOR_NEW HomogeneousPoint(const T &value=T())
Default constructor - sets all elements to the same value.
ecl::linear_algebra::Matrix< T, 4, 1 > & positionVector()
Representation of the position vector in eigen vector format.
HomogeneousPoint(const ecl::linear_algebra::Matrix< T, 3, 1 > &vec)
Initialises with the specified eigen style vector.
OutputStream & operator<<(OutputStream &ostream, const Array< ElementType, ArraySize > &array)
Embedded control libraries.
#define LOC
const T & y() const
Returns a constant reference to the y co-ordinate.
HomogeneousPoint< double > HomogeneousPointd
Eigen style convenience handle for homogeneous points in double format.
HomogeneousPoint< float > HomogeneousPointf
Eigen style convenience handle for homogeneous points in float format.
#define ecl_assert_throw(expression, exception)
InvalidInputError
const T & z() const
Returns a constant reference to the z co-ordinate.
const T & x() const
Returns a constant reference to the x co-ordinate.
const ecl::linear_algebra::Matrix< T, 4, 1 > & positionVector() const
Representation of the position vector in const eigen vector format.
Dummy parent class for Homogenous points.
HomogeneousPoint(const ecl::linear_algebra::Matrix< T, 4, 1 > &vec)
Initialises with the specified eigen style vector in homogeneous format.
HomogeneousPoint(const T &x_i, const T &y_i, const T &z_i)
Initialises the point with the specified values.


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:49