Aim: Implements basic operations that will be used in Point and Vector classes.
More...
|
| BOOST_CONCEPT_ASSERT ((concepts::CEuclideanRing< TEuclideanRing >)) |
|
| PointVector () |
| Constructor. More...
|
|
| PointVector (const Component *ptrValues) |
| Constructor from array of values. More...
|
|
| PointVector (const Component &x, const Component &y) |
| Constructor from two values (the Dimension of the vector should be at least 2). Other components are set to 0. More...
|
|
| PointVector (const Component &x, const Component &y, const Component &z) |
| Constructor from three values (the Dimension of the vector should be at least 3). Other components are set to 0. More...
|
|
| PointVector (const Component &x, const Component &y, const Component &z, const Component &t) |
| Constructor from four values (the Dimension of the vector should be at least 4). Other components are set to 0. More...
|
|
| PointVector (std::initializer_list< Component > init) |
| Constructor from initializer list. More...
|
|
template<typename LeftComponent , typename LeftStorage , typename RightComponent , typename RightStorage , typename BinaryFunctor > |
| PointVector (const PointVector< dim, LeftComponent, LeftStorage > &apoint1, const PointVector< dim, RightComponent, RightStorage > &apoint2, const BinaryFunctor &f) |
| Constructor taking two points and a functor as parameters. More...
|
|
template<typename OtherComponent , typename OtherStorage , typename UnaryFunctor > |
| PointVector (const PointVector< dim, OtherComponent, OtherStorage > &apoint1, const UnaryFunctor &f) |
| Constructor taking a point and a unary functor as parameters. More...
|
|
| ~PointVector () |
| Destructor. More...
|
|
| PointVector (const Self &other) |
| Copy constructor. More...
|
|
template<typename OtherComponent , typename OtherCont , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
| PointVector (const PointVector< dim, OtherComponent, OtherCont > &other) |
| Copy constructor from another component PointVector. More...
|
|
template<typename OtherComponent , typename OtherCont , typename std::enable_if< ! std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
| PointVector (const PointVector< dim, OtherComponent, OtherCont > &other) |
| Copy constructor from another component PointVector. More...
|
|
Self & | operator= (const Self &pv) |
| Assignement Operator. More...
|
|
template<typename OtherComponent , typename OtherContainer , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
Self & | operator= (const PointVector< dim, OtherComponent, OtherContainer > &v) |
| Assignment operator from PointVector with different component type. More...
|
|
template<typename OtherComponent , typename OtherContainer , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
Self & | partialCopy (const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) |
| Partial copy of a given PointVector. More...
|
|
template<typename OtherComponent , typename OtherContainer , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
Self & | partialCopyInv (const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) |
| Partial copy of a given PointVector. More...
|
|
template<typename OtherComponent , typename OtherContainer , typename UnaryFunctor > |
Self & | partialCopy (const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions, const UnaryFunctor &f) |
| Partial copy of a given PointVector using a functor. More...
|
|
template<typename OtherComponent , typename OtherContainer , typename UnaryFunctor > |
Self & | partialCopyInv (const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions, const UnaryFunctor &f) |
| Partial copy of a given PointVector using a functor. More...
|
|
template<typename OtherComponent , typename OtherContainer > |
bool | partialEqual (const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) const |
| Partial equality. More...
|
|
template<typename OtherComponent , typename OtherContainer > |
bool | partialEqualInv (const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions) const |
| Partial inverse equality. More...
|
|
Iterator | begin () |
|
Iterator | end () |
|
ConstIterator | begin () const |
|
ConstIterator | end () const |
|
ReverseIterator | rbegin () |
|
ReverseIterator | rend () |
|
ConstReverseIterator | rbegin () const |
|
ConstReverseIterator | rend () const |
|
const Component * | data () const noexcept |
|
Component * | data () noexcept |
|
Dimension | rows () const |
|
const Component & | operator[] (Dimension i) const |
|
const Component & | operator() (Dimension i) const |
|
Component & | operator[] (Dimension i) |
|
Component & | operator() (Dimension i) |
|
template<typename OtherComponent , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator+= (OtherComponent coeff) |
| Adds the coeff scalar number to *this. More...
|
|
template<typename OtherComponent , typename OtherStorage , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator+= (PointVector< dim, OtherComponent, OtherStorage > const &v) |
| Adds the v vector/point to *this, componentwise. More...
|
|
template<typename OtherComponent , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator-= (OtherComponent coeff) |
| Subtracts the coeff scalar number to *this. More...
|
|
template<typename OtherComponent , typename OtherStorage , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator-= (PointVector< dim, OtherComponent, OtherStorage > const &v) |
| Subtracts the v vector/point to *this, componentwise. More...
|
|
template<typename OtherComponent , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator*= (OtherComponent coeff) |
| Multiplies *this by the coeff scalar number. More...
|
|
template<typename OtherComponent , typename OtherStorage , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator*= (PointVector< dim, OtherComponent, OtherStorage > const &v) |
| Multiplies *this by the v vector/point, componentwise. More...
|
|
template<typename OtherComponent , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator/= (OtherComponent coeff) |
| Divides *this by the coeff scalar number. More...
|
|
template<typename OtherComponent , typename OtherStorage , typename std::enable_if< std::is_same< Component, ArithmeticConversionType< Component, OtherComponent > >::value, int >::type = 0> |
PointVector & | operator/= (PointVector< dim, OtherComponent, OtherStorage > const &v) |
| Divides *this by the v vector/point, componentwise. More...
|
|
Self | operator- () const |
| Unary minus operator. More...
|
|
template<typename OtherComponent , typename OtherStorage > |
auto | dot (const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v)) |
| Dot product with a PointVector. More...
|
|
template<typename OtherComponent , typename OtherStorage > |
auto | crossProduct (const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v)) |
| Cross product with a PointVector. More...
|
|
template<typename OtherComponent , typename OtherStorage > |
double | cosineSimilarity (const PointVector< dim, OtherComponent, OtherStorage > &v) const |
| Positive angle between two vectors, deduced from their scalar product. More...
|
|
template<typename OtherComponent , typename OtherStorage > |
auto | inf (const PointVector< dim, OtherComponent, OtherStorage > &aPoint) const -> decltype(DGtal::inf(*this, aPoint)) |
| Implements the infimum (or greatest lower bound). More...
|
|
template<typename OtherComponent , typename OtherStorage > |
auto | sup (const PointVector< dim, OtherComponent, OtherStorage > &aPoint) const -> decltype(DGtal::sup(*this, aPoint)) |
| Implements the supremum (or least upper bound). More...
|
|
template<typename OtherComponent , typename OtherStorage > |
bool | isLower (const PointVector< dim, OtherComponent, OtherStorage > &p) const |
| Return true if this point is below a given point. More...
|
|
template<typename OtherComponent , typename OtherStorage > |
bool | isUpper (const PointVector< dim, OtherComponent, OtherStorage > &p) const |
| Return true if this point is upper a given point. More...
|
|
Component | max () const |
|
Component | min () const |
|
Iterator | maxElement () |
|
Iterator | minElement () |
|
void | negate () |
|
double | norm (const NormType type=L_2) const |
|
double | squaredNorm () const |
|
UnsignedComponent | norm1 () const |
|
UnsignedComponent | normInfinity () const |
|
PointVector< dim, double, std::array< double, dim > > | getNormalized () const |
|
void | reset () |
| Resets all the values to zero. More...
|
|
void | clear () |
| Resets all the values to zero. More...
|
|
std::string | className () const |
|
void | selfDisplay (std::ostream &out) const |
|
bool | isValid () const |
|
|
template<DGtal::Dimension otherDim, typename TOtherEuclideanRing , typename TOtherContainer > |
class | PointVector |
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
bool | operator== (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) |
| Equality operator between two Points/Vectors. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
bool | operator!= (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) |
| Difference operator on Points/Vectors. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
bool | operator< (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) |
| Comparison operator on Points/Vectors (LesserThan). More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
bool | operator<= (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) |
| Comparison operator on Points/Vectors (LesserOrEqualThan). More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
bool | operator>= (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) |
| Comparison operator on Points/Vectors (GreaterOrEqualThan). More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
auto | operator- (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Subtraction operator between two Points/Vectors. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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. More...
|
|
template<DGtal::Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightScalar > |
auto | operator+ (DGtal::PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, RightScalar const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Addition operator between a Point/Vector and a scalar. More...
|
|
template<Dimension ptDim, typename LeftScalar , typename RightEuclideanRing , typename RightContainer > |
auto | operator+ (LeftScalar const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Addition operator between a scalar and a Point/Vector. More...
|
|
template<DGtal::Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightScalar > |
auto | operator- (DGtal::PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, RightScalar const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Subtraction operator between a Point/Vector and a scalar. More...
|
|
template<Dimension ptDim, typename LeftScalar , typename RightEuclideanRing , typename RightContainer > |
auto | operator- (LeftScalar const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Substraction operator between a scalar and a Point/Vector. More...
|
|
template<DGtal::Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightScalar > |
auto | operator* (DGtal::PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, RightScalar const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Multiplication operator between a Point/Vector and a scalar. More...
|
|
template<Dimension ptDim, typename LeftScalar , typename RightEuclideanRing , typename RightContainer > |
auto | operator* (LeftScalar const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Multiplication operator between a scalar and a Point/Vector. More...
|
|
template<DGtal::Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightScalar > |
auto | operator/ (DGtal::PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, RightScalar const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Division operator between a Point/Vector and a scalar. More...
|
|
template<Dimension ptDim, typename LeftScalar , typename RightEuclideanRing , typename RightContainer > |
auto | operator/ (LeftScalar const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs)) |
| Division operator between a scalar and a Point/Vector. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
DGtal::ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > | dotProduct (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) |
| Dot product between two points/vectors. More...
|
|
template<typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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. More...
|
|
template<typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
PointVector< 3, DGtal::ArithmeticConversionType< LeftEuclideanRing, RightEuclideanRing > > | crossProduct (PointVector< 2, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< 2, RightEuclideanRing, RightContainer > const &rhs) |
| Cross product of two 2D Points/Vectors. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
double | cosineSimilarity (PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs) |
| Positive angle between two vectors, deduced from their scalar product. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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). More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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). More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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. More...
|
|
template<Dimension ptDim, typename LeftEuclideanRing , typename LeftContainer , typename RightEuclideanRing , typename RightContainer > |
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. More...
|
|
template<
DGtal::Dimension dim, typename TEuclideanRing, typename TContainer>
class DGtal::PointVector< dim, TEuclideanRing, TContainer >
Aim: Implements basic operations that will be used in Point and Vector classes.
Description of class 'PointVector'
A PointVector may represent either a symbolic point or a symbolic vector depending on the context. The coordinates of the point or the components of the vector should be part of a ring. For performance reasons, these two types are just aliases. The user should take care how to use it depending on the context. For instance, adding two points has no meaning, but will be authorized by the compiler.
- Template Parameters
-
dim | static constant of type DGtal::Dimension that specifies the static dimension of the space and thus the number of elements of the Point or Vector. |
TEuclideanRing | speficies the number type assoicated to an Euclidean domain (or Euclidean ring) algebraic structure (commutative unitary ring with no zero divisors and with a division operator but not necessarily an inverse for the multiplication operator). This type is used to represent PointVector elements (Coordinate for Point and Component for Vector) and define operations on Point or Vectors. |
TContainer | specifies the container to be used to store the point coordinates. At this point, such container must be a random access bidirectionnal a-la STL containers (e.g. vector, boost/array). If TContainer implements comparison operators == != < <= > <=, then PointVector will also implements it and with the exact same behaviour. |
All operations involving PointVector, and some of its methods, follow the classical arithmetic conversion rules. More precisely, if an operation involves two component types T and U, then the result will have the type of T() + U()
as component type, that is the last of T and U in the following conversion chain:
boost::int64_t int64_t
signed 94-bit integer.
boost::uint32_t uint32_t
unsigned 32-bit integer.
boost::uint16_t uint16_t
unsigned 16-bit integer.
boost::uint8_t uint8_t
unsigned 8-bit integer.
boost::uint64_t uint64_t
unsigned 64-bit integer.
boost::int32_t int32_t
signed 32-bit integer.
boost::int8_t int8_t
signed 8-bit integer.
boost::int16_t int16_t
signed 16-bit integer.
A consequence is that if the result is stored in a PointVector whose component type has lower rank than the result type in the conversion chain above, then it will result in a compilation error. This behavior is designed to avoid unwanted conversions that may lead to loss of precision.
This constraint can be dodged by using one of the conversion constructor (explicitly or along with a conversion functor) or equivalent methods.
- See also
- ArithmeticConversionTraits
-
https://en.cppreference.com/w/cpp/language/operator_arithmetic#Conversions
For example, dividing a PointVector with integer components by an integer uses the Euclidean division and returns a PointVector with higher integer component type. On the other hand, dividing a PointVector with integer components by a double will use classical division on real numbers and returns a PointVector with double component type.
PointVector also realizes the concept CLattice with an infimum (meet, greatest lower bound) and a supremum (join, least upper bound) operation.
Usage example:
...
VectorD5 p, q, r;
p[1] = 2;
q[3] = -5
r = p + q ;
...
Aim: Implements basic operations that will be used in Point and Vector classes.
PointVector is a model of CBidirectionalRange.
- See also
- testPointVector.cpp
- Examples
- dec/exampleDiscreteExteriorCalculusSolve.cpp, dec/exampleHeatLaplace.cpp, doc-examples/exampleCatch.cpp, geometry/curves/exampleArithDSS3d.cpp, geometry/surfaces/dvcm-3d.cpp, geometry/tools/determinant/exampleInHalfPlane.cpp, geometry/volumes/dvcm-2d.cpp, images/extract2DImagesFrom3D.cpp, images/extract2DImagesFrom3DandVisu.cpp, io/boards/exampleBezierCurve.cpp, io/viewers/viewer3D-8bis-2Dimages.cpp, shapes/exampleEuclideanShapesDecorator.cpp, tutorial-examples/AreaSurfaceEstimation-final.cpp, and tutorial-examples/volDTGranulo.cpp.
Definition at line 592 of file PointVector.h.