DGtal  1.0.0
PointVector.h
1 
17 #pragma once
18 
34 #if defined(PointVector_RECURSES)
35 #error Recursive header files inclusion detected in PointVector.h
36 #else // defined(PointVector_RECURSES)
37 
38 #define PointVector_RECURSES
39 
40 #if !defined PointVector_h
41 
42 #define PointVector_h
43 
45 // Inclusions
46 #include <iostream>
47 #include <string>
48 #include <bitset>
49 #include <algorithm>
50 #include <array>
51 #include <vector>
52 #include <type_traits>
53 #include <utility>
54 #include <functional>
55 
56 #include "DGtal/base/Common.h"
57 #include "DGtal/base/CBidirectionalRange.h"
58 #include "DGtal/kernel/NumberTraits.h"
59 #include "DGtal/kernel/CEuclideanRing.h"
60 #include "DGtal/kernel/ArithmeticConversionTraits.h"
61 
63 
64 namespace DGtal
65 {
67  template<Dimension dim, typename Container>
68  std::bitset<dim> setDimensionsIn( const Container &dimensions );
69 
71  template<Dimension dim, typename Container>
72  std::bitset<dim> setDimensionsNotIn( const Container &dimensions );
73 
75  // class PointVector pre-declaration
162  template < DGtal::Dimension dim,
163  typename TEuclideanRing,
164  typename TContainer=std::array<TEuclideanRing,dim> >
165  class PointVector;
166 
168  // Type traits
169 
174  template <typename T>
175  struct IsAPointVector : std::false_type {};
176 
181  template <DGtal::Dimension dim, typename TEuclideanRing, typename TContainer>
182  struct IsAPointVector<PointVector<dim, TEuclideanRing, TContainer>> : std::true_type {};
183 
188  template < DGtal::Dimension dim,
189  typename LeftEuclideanRing, typename LeftContainer,
190  typename RightEuclideanRing, typename RightContainer >
191  struct ArithmeticConversionTraits< PointVector<dim, LeftEuclideanRing, LeftContainer>, PointVector<dim, RightEuclideanRing, RightContainer>,
192  typename std::enable_if< IsArithmeticConversionValid<LeftEuclideanRing, RightEuclideanRing>::value >::type >
193  {
194  using type = typename std::conditional<
195  std::is_same< LeftEuclideanRing, ArithmeticConversionType<LeftEuclideanRing, RightEuclideanRing> >::value,
198  };
199 
204  template < DGtal::Dimension dim,
205  typename LeftEuclideanRing, typename LeftContainer,
206  typename RightEuclideanRing >
207  struct ArithmeticConversionTraits< PointVector<dim, LeftEuclideanRing, LeftContainer>, RightEuclideanRing,
208  typename std::enable_if<
209  IsArithmeticConversionValid<LeftEuclideanRing, RightEuclideanRing>::value
210  && ! IsAPointVector<RightEuclideanRing>::value >::type >
211  {
212  using type = typename std::conditional<
213  std::is_same< LeftEuclideanRing, ArithmeticConversionType<LeftEuclideanRing, RightEuclideanRing> >::value,
216  };
217 
222  template < DGtal::Dimension dim,
223  typename LeftEuclideanRing,
224  typename RightEuclideanRing, typename RightContainer >
225  struct ArithmeticConversionTraits< LeftEuclideanRing, PointVector<dim, RightEuclideanRing, RightContainer>,
226  typename std::enable_if<
227  IsArithmeticConversionValid<LeftEuclideanRing, RightEuclideanRing>::value
228  && ! IsAPointVector<LeftEuclideanRing>::value >::type >
229  {
230  using type = typename std::conditional<
231  std::is_same< LeftEuclideanRing, ArithmeticConversionType<LeftEuclideanRing, RightEuclideanRing> >::value,
234  };
235 
236 
238  // PointVector comparison operators
239 
244  template < Dimension ptDim,
245  typename LeftEuclideanRing, typename LeftContainer,
246  typename RightEuclideanRing, typename RightContainer >
247  inline bool
250 
255  template < Dimension ptDim,
256  typename LeftEuclideanRing, typename LeftContainer,
257  typename RightEuclideanRing, typename RightContainer >
258  inline bool
261 
268  template < Dimension ptDim,
269  typename LeftEuclideanRing, typename LeftContainer,
270  typename RightEuclideanRing, typename RightContainer >
271  inline bool
274 
281  template < Dimension ptDim,
282  typename LeftEuclideanRing, typename LeftContainer,
283  typename RightEuclideanRing, typename RightContainer >
284  inline bool
287 
294  template < Dimension ptDim,
295  typename LeftEuclideanRing, typename LeftContainer,
296  typename RightEuclideanRing, typename RightContainer >
297  inline bool
300 
307  template < Dimension ptDim,
308  typename LeftEuclideanRing, typename LeftContainer,
309  typename RightEuclideanRing, typename RightContainer >
310  inline bool
313 
315  // Binary arithmetics operators between two PointVectors
316 
322  template < Dimension ptDim,
323  typename LeftEuclideanRing, typename LeftContainer,
324  typename RightEuclideanRing, typename RightContainer >
325  inline auto
328  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
329 
335  template < Dimension ptDim,
336  typename LeftEuclideanRing, typename LeftContainer,
337  typename RightEuclideanRing, typename RightContainer >
338  inline auto
341  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
342 
348  template < Dimension ptDim,
349  typename LeftEuclideanRing, typename LeftContainer,
350  typename RightEuclideanRing, typename RightContainer >
351  inline auto
354  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
355 
361  template < Dimension ptDim,
362  typename LeftEuclideanRing, typename LeftContainer,
363  typename RightEuclideanRing, typename RightContainer >
364  inline auto
367  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
368 
370  // Binary arithmetics operators between a PointVector and a scalar
371 
377  template < Dimension ptDim,
378  typename LeftEuclideanRing, typename LeftContainer,
379  typename RightScalar >
380  inline auto
382  RightScalar const& rhs )
383  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
384 
390  template < Dimension ptDim,
391  typename LeftScalar,
392  typename RightEuclideanRing, typename RightContainer >
393  inline auto
394  operator+ ( LeftScalar const& lhs,
396  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
397 
403  template < Dimension ptDim,
404  typename LeftEuclideanRing, typename LeftContainer,
405  typename RightScalar >
406  inline auto
408  RightScalar const& rhs )
409  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
410 
416  template < Dimension ptDim,
417  typename LeftScalar,
418  typename RightEuclideanRing, typename RightContainer >
419  inline auto
420  operator- ( LeftScalar const& lhs,
422  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
423 
429  template < Dimension ptDim,
430  typename LeftEuclideanRing, typename LeftContainer,
431  typename RightScalar >
432  inline auto
434  RightScalar const& rhs )
435  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
436 
442  template < Dimension ptDim,
443  typename LeftScalar,
444  typename RightEuclideanRing, typename RightContainer >
445  inline auto
446  operator* ( LeftScalar const& lhs,
448  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
449 
455  template < Dimension ptDim,
456  typename LeftEuclideanRing, typename LeftContainer,
457  typename RightScalar >
458  inline auto
460  RightScalar const& rhs )
461  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
462 
468  template < Dimension ptDim,
469  typename LeftScalar,
470  typename RightEuclideanRing, typename RightContainer >
471  inline auto
472  operator/ ( LeftScalar const& lhs,
474  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
475 
477  // Operations between Points/Vectors
478 
484  template < Dimension ptDim,
485  typename LeftEuclideanRing, typename LeftContainer,
486  typename RightEuclideanRing, typename RightContainer >
487  inline
491 
497  template <
498  typename LeftEuclideanRing, typename LeftContainer,
499  typename RightEuclideanRing, typename RightContainer >
500  inline auto
503  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
504 
510  template <
511  typename LeftEuclideanRing, typename LeftContainer,
512  typename RightEuclideanRing, typename RightContainer >
513  inline
517 
522  template < Dimension ptDim,
523  typename LeftEuclideanRing, typename LeftContainer,
524  typename RightEuclideanRing, typename RightContainer >
525  inline double
528 
538  template < Dimension ptDim,
539  typename LeftEuclideanRing, typename LeftContainer,
540  typename RightEuclideanRing, typename RightContainer >
541  inline auto
544  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
545 
555  template < Dimension ptDim,
556  typename LeftEuclideanRing, typename LeftContainer,
557  typename RightEuclideanRing, typename RightContainer >
558  inline auto
561  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
562 
568  template < Dimension ptDim,
569  typename LeftEuclideanRing, typename LeftContainer,
570  typename RightEuclideanRing, typename RightContainer >
571  inline bool
574 
580  template < Dimension ptDim,
581  typename LeftEuclideanRing, typename LeftContainer,
582  typename RightEuclideanRing, typename RightContainer >
583  inline bool
586 
588  // class PointVector full declaration
589  template < DGtal::Dimension dim,
590  typename TEuclideanRing,
591  typename TContainer >
592  class PointVector
593  {
594 
595  // Friend with all PointVectors
596  template <
597  DGtal::Dimension otherDim,
598  typename TOtherEuclideanRing,
599  typename TOtherContainer >
600  friend class PointVector;
601 
602  // ----------------------- Standard services ------------------------------
603  public:
604 
606 
609 
612 
614  typedef TEuclideanRing Component;
615 
618 
621 
624 
626  static const Dimension dimension = dim;
627 
629  typedef Component Scalar;
630  typedef Dimension Index;
631 
633  typedef TContainer Container;
634 
635 
640  typedef typename Container::iterator Iterator;
641  typedef typename Container::const_iterator ConstIterator;
642  typedef typename Container::reverse_iterator ReverseIterator;
643  typedef typename Container::const_reverse_iterator ConstReverseIterator;
644 
648  PointVector();
649 
656  explicit PointVector( const Component* ptrValues );
657 
665  PointVector( const Component & x, const Component & y );
666 
675  PointVector( const Component & x, const Component & y, const Component & z );
676 
686  PointVector( const Component & x, const Component & y,
687  const Component & z, const Component & t );
688 
693  PointVector( std::initializer_list<Component> init );
694 
700  template <
701  typename LeftComponent, typename LeftStorage,
702  typename RightComponent, typename RightStorage,
703  typename BinaryFunctor >
706  const BinaryFunctor& f );
707 
713  template <
714  typename OtherComponent, typename OtherStorage,
715  typename UnaryFunctor >
717  const UnaryFunctor & f );
718 
722  ~PointVector();
723 
724  // ----------------------- Standard services ------------------------------
725 
726  public:
731  PointVector( const Self & other );
732 
742  template <
743  typename OtherComponent, typename OtherCont,
744  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
746 
756  template <
757  typename OtherComponent, typename OtherCont,
758  typename std::enable_if< ! std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
759  explicit
761 
767  Self & operator= ( const Self & pv );
768 
780  template <
781  typename OtherComponent,
782  typename OtherContainer,
783  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
785 
803  template <
804  typename OtherComponent,
805  typename OtherContainer,
806  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
808  const std::vector<Dimension> &dimensions);
809 
827  template <
828  typename OtherComponent,
829  typename OtherContainer,
830  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
832  const std::vector<Dimension> &dimensions);
833 
849  template <
850  typename OtherComponent,
851  typename OtherContainer,
852  typename UnaryFunctor >
854  const std::vector<Dimension> & dimensions,
855  const UnaryFunctor & f);
856 
872  template <
873  typename OtherComponent,
874  typename OtherContainer,
875  typename UnaryFunctor >
877  const std::vector<Dimension> & dimensions,
878  const UnaryFunctor & f);
879 
892  template <
893  typename OtherComponent,
894  typename OtherContainer >
896  const std::vector<Dimension> &dimensions ) const;
897 
910  template <
911  typename OtherComponent,
912  typename OtherContainer >
914  const std::vector<Dimension> &dimensions ) const;
915 
916  // ----------------------- Iterator services ------------------------------
917  public:
923  Iterator begin();
924 
930  Iterator end();
931 
937  ConstIterator begin() const;
938 
944  ConstIterator end() const;
945 
952 
959 
966 
972  ConstReverseIterator rend() const;
973 
974  // ----------------------- Array services ------------------------------
975  public:
980  static Dimension size();
981  inline Dimension rows() const { return dim; }
982 
990  const Component& operator[]( Dimension i ) const;
991  inline const Component& operator()( Dimension i ) const { return (*this)[i]; }
992 
1002  Component& operator()(Dimension i ) { return (*this)[i]; }
1003 
1004  // ----------------------- Comparison operations --------------------------
1005  // Friend declarations in order to have them documented on the same page
1006  // as PointVector.
1007  public:
1008 
1009  template < Dimension ptDim,
1010  typename LeftEuclideanRing, typename LeftContainer,
1011  typename RightEuclideanRing, typename RightContainer >
1012  friend inline bool
1015 
1016  template < Dimension ptDim,
1017  typename LeftEuclideanRing, typename LeftContainer,
1018  typename RightEuclideanRing, typename RightContainer >
1019  friend inline bool
1022 
1023  template < Dimension ptDim,
1024  typename LeftEuclideanRing, typename LeftContainer,
1025  typename RightEuclideanRing, typename RightContainer >
1026  friend inline bool
1029 
1030  template < Dimension ptDim,
1031  typename LeftEuclideanRing, typename LeftContainer,
1032  typename RightEuclideanRing, typename RightContainer >
1033  friend inline bool
1036 
1037  template < Dimension ptDim,
1038  typename LeftEuclideanRing, typename LeftContainer,
1039  typename RightEuclideanRing, typename RightContainer >
1040  friend inline bool
1043 
1044  // ------------- Binary arithmetic operations between points --------------
1045  // Friend declarations in order to have them documented on the same page
1046  // as PointVector.
1047  public:
1048 
1049  template < Dimension ptDim,
1050  typename LeftEuclideanRing, typename LeftContainer,
1051  typename RightEuclideanRing, typename RightContainer >
1052  friend inline auto
1055  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1056 
1057  template < Dimension ptDim,
1058  typename LeftEuclideanRing, typename LeftContainer,
1059  typename RightEuclideanRing, typename RightContainer >
1060  friend inline auto
1063  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1064 
1065  template < Dimension ptDim,
1066  typename LeftEuclideanRing, typename LeftContainer,
1067  typename RightEuclideanRing, typename RightContainer >
1068  friend inline auto
1071  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1072 
1073  template < Dimension ptDim,
1074  typename LeftEuclideanRing, typename LeftContainer,
1075  typename RightEuclideanRing, typename RightContainer >
1076  friend inline auto
1079  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1080 
1081  // ------ Binary arithmetic operations between a point and a vector -------
1082  // Friend declarations in order to have them documented on the same page
1083  // as PointVector.
1084  public:
1085 
1086  template < DGtal::Dimension ptDim,
1087  typename LeftEuclideanRing, typename LeftContainer,
1088  typename RightScalar >
1089  friend inline auto
1091  RightScalar const& rhs )
1092  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1093 
1094  template < Dimension ptDim,
1095  typename LeftScalar,
1096  typename RightEuclideanRing, typename RightContainer >
1097  friend inline auto
1098  operator+ ( LeftScalar const& lhs,
1100  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1101 
1102  template < DGtal::Dimension ptDim,
1103  typename LeftEuclideanRing, typename LeftContainer,
1104  typename RightScalar >
1105  friend inline auto
1107  RightScalar const& rhs )
1108  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1109 
1110  template < Dimension ptDim,
1111  typename LeftScalar,
1112  typename RightEuclideanRing, typename RightContainer >
1113  friend inline auto
1114  operator- ( LeftScalar const& lhs,
1116  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1117 
1118  template < DGtal::Dimension ptDim,
1119  typename LeftEuclideanRing, typename LeftContainer,
1120  typename RightScalar >
1121  friend inline auto
1123  RightScalar const& rhs )
1124  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1125 
1126  template < Dimension ptDim,
1127  typename LeftScalar,
1128  typename RightEuclideanRing, typename RightContainer >
1129  friend inline auto
1130  operator* ( LeftScalar const& lhs,
1132  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1133 
1134  template < DGtal::Dimension ptDim,
1135  typename LeftEuclideanRing, typename LeftContainer,
1136  typename RightScalar >
1137  friend inline auto
1139  RightScalar const& rhs )
1140  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1141 
1142  template < Dimension ptDim,
1143  typename LeftScalar,
1144  typename RightEuclideanRing, typename RightContainer >
1145  friend inline auto
1146  operator/ ( LeftScalar const& lhs,
1148  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1149 
1150  // -------- Unary arithmetic operations on a point or a vector ------------
1151  public:
1152 
1163  template <
1164  typename OtherComponent,
1165  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1166  inline
1167  PointVector & operator+= ( OtherComponent coeff );
1168 
1179  template <
1180  typename OtherComponent, typename OtherStorage,
1181  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1182  inline
1184 
1195  template <
1196  typename OtherComponent,
1197  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1198  inline
1199  PointVector & operator-= ( OtherComponent coeff );
1200 
1211  template <
1212  typename OtherComponent, typename OtherStorage,
1213  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1214  inline
1216 
1227  template <
1228  typename OtherComponent,
1229  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1230  inline
1231  PointVector & operator*= ( OtherComponent coeff );
1232 
1243  template <
1244  typename OtherComponent, typename OtherStorage,
1245  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1246  inline
1248 
1259  template <
1260  typename OtherComponent,
1261  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1262  inline
1263  PointVector & operator/= ( OtherComponent coeff );
1264 
1275  template <
1276  typename OtherComponent, typename OtherStorage,
1277  typename std::enable_if< std::is_same< Component, ArithmeticConversionType<Component, OtherComponent> >::value, int >::type = 0 >
1278  inline
1280 
1287  inline
1288  Self operator-() const;
1289 
1290 
1291  // ------------------ Other operators between vectors ---------------------
1292  public:
1301  template < typename OtherComponent, typename OtherStorage >
1302  inline auto
1304  -> decltype( DGtal::dotProduct(*this, v) );
1305 
1306  template < Dimension ptDim,
1307  typename LeftEuclideanRing, typename LeftContainer,
1308  typename RightEuclideanRing, typename RightContainer >
1309  friend inline
1313 
1325  template < typename OtherComponent, typename OtherStorage >
1326  inline auto
1328  -> decltype( DGtal::crossProduct(*this, v) );
1329 
1330  template <
1331  typename LeftEuclideanRing, typename LeftContainer,
1332  typename RightEuclideanRing, typename RightContainer >
1333  friend inline auto
1336  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1337 
1338  template <
1339  typename LeftEuclideanRing, typename LeftContainer,
1340  typename RightEuclideanRing, typename RightContainer >
1341  friend inline
1345 
1352  template < typename OtherComponent, typename OtherStorage >
1353  inline double
1355 
1356  template < Dimension ptDim,
1357  typename LeftEuclideanRing, typename LeftContainer,
1358  typename RightEuclideanRing, typename RightContainer >
1359  friend inline double
1362 
1373  template < typename OtherComponent, typename OtherStorage >
1374  inline auto
1376  -> decltype( DGtal::inf(*this, aPoint) );
1377 
1378  template < Dimension ptDim,
1379  typename LeftEuclideanRing, typename LeftContainer,
1380  typename RightEuclideanRing, typename RightContainer >
1381  friend inline auto
1384  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1385 
1396  template < typename OtherComponent, typename OtherStorage >
1397  inline auto
1399  -> decltype( DGtal::sup(*this, aPoint) );
1400 
1401  template < Dimension ptDim,
1402  typename LeftEuclideanRing, typename LeftContainer,
1403  typename RightEuclideanRing, typename RightContainer >
1404  friend inline auto
1407  -> decltype( DGtal::constructFromArithmeticConversion(lhs, rhs) );
1408 
1415  template < typename OtherComponent, typename OtherStorage >
1417 
1418  template < Dimension ptDim,
1419  typename LeftEuclideanRing, typename LeftContainer,
1420  typename RightEuclideanRing, typename RightContainer >
1421  friend inline bool
1424 
1431  template < typename OtherComponent, typename OtherStorage >
1433 
1434  template < Dimension ptDim,
1435  typename LeftEuclideanRing, typename LeftContainer,
1436  typename RightEuclideanRing, typename RightContainer >
1437  friend inline bool
1440 
1446  Component max() const;
1447 
1453  Component min() const;
1454 
1461  Iterator maxElement() ;
1462 
1469  Iterator minElement() ;
1470 
1474  void negate();
1475 
1480  enum NormType { L_2, L_1, L_infty };
1481 
1493  double norm( const NormType type = L_2 ) const;
1494 
1503  double squaredNorm( ) const;
1504 
1505 
1511  UnsignedComponent norm1() const;
1512 
1519 
1520 
1529 
1532  void reset();
1533 
1538  inline void clear() { reset(); }
1539 
1540 
1541 
1542  // ------------------------- Standard vectors ------------------------------
1543  public:
1544 
1549  static Self diagonal( Component val = 1 );
1550 
1556  static Self base( Dimension k, Component val = 1 );
1557 
1558  // --------------- CDrawableWithBoard2D realization -------------------
1559  public:
1560 
1564  std::string className() const;
1565 
1566  // ----------------------- Interface --------------------------------------
1567  public:
1568 
1573  void selfDisplay( std::ostream & out ) const;
1574 
1579  bool isValid() const;
1580 
1582  static Self zero;
1583 
1584  // ------------------------- Hidden services ------------------------------
1585  protected:
1586 
1589 
1590  }; // end of class PointVector
1591 
1593  template<Dimension dim, typename Component, typename TC>
1594  std::ostream&
1595  operator<<( std::ostream & out, const PointVector<dim, Component, TC> & object );
1596 
1598  template< Dimension dim, typename Component, typename TC>
1600 
1601 } // namespace DGtal
1602 
1604 // Includes inline functions
1605 #include "DGtal/kernel/PointVector.ih"
1606 
1607 // //
1609 
1610 #endif // !defined PointVector_h
1611 
1612 #undef PointVector_RECURSES
1613 #endif // else defined(PointVector_RECURSES)
const Point aPoint(3, 4)
ArithmeticConversionType< LHS, RHS > constructFromArithmeticConversion(LHS const &lhs, RHS const &rhs, Args &&... args)
Call constructor for the result type of an arithmetic operation.
Self operator-() const
Unary minus operator.
friend auto operator/(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Division operator between two Points/Vectors.
Self & operator=(const Self &pv)
Assignement Operator.
friend bool operator<=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserOrEqualThan).
PointVector & operator *=(OtherComponent coeff)
Multiplies *this by the coeff scalar number.
PointVector & operator+=(OtherComponent coeff)
Adds the coeff scalar number to *this.
UnsignedComponent normInfinity() const
Container::reverse_iterator ReverseIterator
Mutable reverse iterator type.
Definition: PointVector.h:642
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
Definition: PointVector.h:626
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
Dimension rows() const
Definition: PointVector.h:981
static Self diagonal(Component val=1)
Component max() const
Aim: Trait class to get result type of arithmetic binary operators between two given types.
std::bitset< dim > setDimensionsNotIn(const Container &dimensions)
DGtal::uint32_t Dimension
Definition: Common.h:127
Component min() const
PointVector()
Constructor.
friend auto operator+(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Addition operator between two Points/Vectors.
PointVector< dim, double, std::array< double, dim > > getNormalized() const
std::decay< T >::type UnsignedVersion
Alias to the unsigned version of the number type.
Definition: NumberTraits.h:90
auto inf(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Implements the infimum (or greatest lower bound).
typename ArithmeticConversionTraits< T, U >::type ArithmeticConversionType
Result type of arithmetic binary operators between two given types.
bool isUpper(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is upper a given point.
DGtal::ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > dotProduct(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Dot product between two points/vectors.
typename std::conditional< std::is_same< LeftEuclideanRing, ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > >::value, PointVector< dim, LeftEuclideanRing, LeftContainer >, PointVector< dim, RightEuclideanRing, RightContainer > >::type type
Definition: PointVector.h:197
auto dot(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v))
Dot product with a PointVector.
ReverseIterator rend()
DGtal::Dimension Dimension
Copy of the dimension type.
Definition: PointVector.h:623
Component Scalar
Types needed by CLinearAlgebraContainer.
Definition: PointVector.h:629
bool isLower(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Return true if the first point is below the second point.
UnsignedComponent norm1() const
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
TContainer Container
Copy of the container type.
Definition: PointVector.h:633
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a PointVector.
bool operator==(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Equality operator between two Points/Vectors.
bool operator<(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserThan).
PointVector & operator-=(OtherComponent coeff)
Subtracts the coeff scalar number to *this.
KForm< Calculus, order, duality > operator-(const KForm< Calculus, order, duality > &form_a, const KForm< Calculus, order, duality > &form_b)
K init(Point(0, 0, 0), Point(512, 512, 512), true)
bool operator>=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (GreaterOrEqualThan).
double squaredNorm() const
Aim: Defines the mathematical concept equivalent to a unitary commutative ring with a division operat...
double cosineSimilarity(const PointVector< dim, OtherComponent, OtherStorage > &v) const
Positive angle between two vectors, deduced from their scalar product.
friend bool operator>=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (GreaterOrEqualThan).
bool partialEqualInv(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) const
Partial inverse equality.
const Component & operator()(Dimension i) const
Definition: PointVector.h:991
ReverseIterator rbegin()
friend bool operator!=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Difference operator on Points/Vectors.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
double norm(const NormType type=L_2) const
Type trait to check if a given type is a PointVector.
Definition: PointVector.h:175
bool isLower(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is below a given point.
Circulator< TIterator > operator+(typename IteratorCirculatorTraits< TIterator >::Difference d, Circulator< TIterator > &object)
Definition: Circulator.h:453
auto crossProduct(PointVector< 3, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< 3, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Cross product of two 3D Points/Vectors.
bool operator!=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Difference operator on Points/Vectors.
auto inf(const PointVector< dim, OtherComponent, OtherStorage > &aPoint) const -> decltype(DGtal::inf(*this, aPoint))
Implements the infimum (or greatest lower bound).
PointVector< dim, TEuclideanRing, TContainer > Self
Self type.
Definition: PointVector.h:611
auto operator/(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Division operator between two Points/Vectors.
BOOST_CONCEPT_ASSERT((concepts::CEuclideanRing< TEuclideanRing >))
NumberTraits< Component >::UnsignedVersion UnsignedComponent
Unsigned version of the components.
Definition: PointVector.h:620
Container::const_iterator ConstIterator
Constant iterator type.
Definition: PointVector.h:641
double cosineSimilarity(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Positive angle between two vectors, deduced from their scalar product.
DGtal is the top-level namespace which contains all DGtal functions and types.
Iterator maxElement()
friend bool operator<(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserThan).
Container::const_reverse_iterator ConstReverseIterator
Constant reverse iterator type.
Definition: PointVector.h:643
static Dimension size()
friend DGtal::ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > dotProduct(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Dot product between two points/vectors.
unsigned int dim(const Vector &z)
static Self base(Dimension k, Component val=1)
std::bitset< dim > setDimensionsIn(const Container &dimensions)
KForm< Calculus, order, duality > operator *(const typename Calculus::Scalar &scalar, const KForm< Calculus, order, duality > &form)
PointVector & operator/=(OtherComponent coeff)
Divides *this by the coeff scalar number.
void reset()
Resets all the values to zero.
bool partialEqual(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) const
Partial equality.
Self & partialCopyInv(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
const Component & operator[](Dimension i) const
typename std::conditional< std::is_same< LeftEuclideanRing, ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > >::value, PointVector< dim, LeftEuclideanRing >, PointVector< dim, RightEuclideanRing, RightContainer > >::type type
Definition: PointVector.h:233
bool isValid() const
Iterator minElement()
bool operator>(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (GreaterThan).
static Self zero
Static const for zero PointVector.
Definition: PointVector.h:1582
Container::iterator Iterator
Mutable iterator type.
Definition: PointVector.h:640
auto sup(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Implements the supremum (or least upper bound).
friend bool operator==(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Equality operator between two Points/Vectors.
Component & operator()(Dimension i)
Definition: PointVector.h:1002
~PointVector()
Destructor.
std::string className() const
void selfDisplay(std::ostream &out) const
Container myArray
Internal data-structure: std::array with constant size.
Definition: PointVector.h:1588
friend auto operator *(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Multiplication operator between two Points/Vectors.
bool operator<=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserOrEqualThan).
auto sup(const PointVector< dim, OtherComponent, OtherStorage > &aPoint) const -> decltype(DGtal::sup(*this, aPoint))
Implements the supremum (or least upper bound).
bool isUpper(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Return true if the first point is upper the second point.
Self & partialCopy(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
typename std::conditional< std::is_same< LeftEuclideanRing, ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > >::value, PointVector< dim, LeftEuclideanRing, LeftContainer >, PointVector< dim, RightEuclideanRing > >::type type
Definition: PointVector.h:215
TEuclideanRing Component
Type for Vector elements.
Definition: PointVector.h:614
void clear()
Resets all the values to zero.
Definition: PointVector.h:1538