|
DGtal 2.1.0
|
Aim: Utility class to determine the affine geometry of an input set of points. It provides exact results when the input is composed of lattice points, and may determine a basis, the dimension, or an orthogonal vector. More...
#include <DGtal/geometry/tools/AffineBasis.h>
Public Types | |
| enum struct | Type { INVALID = 0 , ECHELON_REDUCED , SHORTEST_ECHELON_REDUCED , LLL_REDUCED } |
| typedef AffineBasis< TPoint > | Self |
| typedef TPoint | Point |
| typedef Point::Coordinate | Scalar |
| typedef std::vector< Point > | Points |
| typedef AffineGeometry< Point > | Affine |
Public Member Functions | |
standard services | |
| AffineBasis (const double tolerance=1e-12) | |
| template<typename TInputPoint > | |
| AffineBasis (const std::vector< TInputPoint > &points, AffineBasis::Type type, const double delta=0.99, const double tolerance=1e-12) | |
| template<typename TInputPoint > | |
| AffineBasis (const TInputPoint &origin, const std::vector< TInputPoint > &basis, AffineBasis::Type type, bool is_reduced=false, const double delta=0.99, const double tolerance=1e-12) | |
| template<typename TInputPoint > | |
| AffineBasis (const TInputPoint &origin, const TInputPoint &normal, AffineBasis::Type type=Type::ECHELON_REDUCED, const double tolerance=1e-12) | |
| void | reduce (AffineBasis::Type type, double delta) |
| Dimension | dimension () const |
| const Point & | origin () const |
| const Points & | basis () const |
debug and I/O services | |
| void | selfDisplay (std::ostream &out) const |
| bool | isValid () const |
| std::string | reductionTypeName () const |
Data Fields | |
public data | |
| Point | first |
| the origin of the affine basis | |
| Points | second |
| the vector basis | |
| double | epsilon {1e-12} |
| the accepted value below which a floating-point number is 0. | |
| AffineBasis::Type | _type |
| the type of reduction of the basis. | |
Protected Member Functions | |
protected services | |
| void | normalize () |
| void | reduceAsEchelon (Type type) |
| void | orderEchelonBasis () |
| Guarantees that the basis is in echelon form. | |
| void | reduceAsLLL (double delta, Scalar) |
| template<typename TInputPoint > | |
| void | initBasis (const std::vector< TInputPoint > &basis) |
| void | sortBasis () |
| std::size_t | findIndexWithSmallestNonNullComponent (Dimension k, std::size_t i, const std::vector< Point > &basis) |
geometry services | |
| bool | isParallel (const Self &other) const |
| std::pair< Scalar, Point > | rationalCoordinates (const Point &p) const |
| bool | isOnAffineSpace (const Point &p) const |
| bool | isParallel (const Point &w) const |
| Point | recompose (Scalar d, const Point &lambda, const Point &r=Point::zero) const |
| Point | recomposeVector (Scalar d, const Point &lambda, const Point &r=Point::zero) const |
| std::tuple< Scalar, Point, Point > | decompose (const Point &p) const |
| std::tuple< Scalar, Point, Point > | decomposeVector (Point w) const |
| template<typename ProjectedPoint > | |
| Scalar | projectPoints (std::vector< ProjectedPoint > &result, const Points &input) |
| template<typename OtherPoint > | |
| static void | transform (OtherPoint &pp, const Point &p) |
| template<typename OtherPoint > | |
| static void | dilatedTransform (OtherPoint &pp, const Point &p, Scalar m) |
Aim: Utility class to determine the affine geometry of an input set of points. It provides exact results when the input is composed of lattice points, and may determine a basis, the dimension, or an orthogonal vector.
Description of template class 'AffineBasis'
| TPoint | the type for points, which may be lattice points or points with floating-point coordinates. |
Definition at line 111 of file AffineBasis.h.
| typedef AffineGeometry< Point > DGtal::AffineBasis< TPoint >::Affine |
Definition at line 117 of file AffineBasis.h.
| typedef TPoint DGtal::AffineBasis< TPoint >::Point |
Definition at line 114 of file AffineBasis.h.
| typedef std::vector< Point > DGtal::AffineBasis< TPoint >::Points |
Definition at line 116 of file AffineBasis.h.
| typedef Point::Coordinate DGtal::AffineBasis< TPoint >::Scalar |
Definition at line 115 of file AffineBasis.h.
| typedef AffineBasis<TPoint> DGtal::AffineBasis< TPoint >::Self |
Definition at line 113 of file AffineBasis.h.
|
strong |
| Enumerator | |
|---|---|
| INVALID | invalid basis |
| ECHELON_REDUCED | echelon matrix |
| SHORTEST_ECHELON_REDUCED | echelon matrix starting from shortest vectors |
| LLL_REDUCED | delta-LLL reduced matrix |
Definition at line 119 of file AffineBasis.h.
|
inline |
Default constructor. This create the identity basis of the space.
| [in] | tolerance | the accepted oo-norm below which the vector is null (used only for points with float/double coordinates). |
Definition at line 137 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, DGtal::AffineBasis< TPoint >::first, DGtal::AffineBasis< TPoint >::second, and DGtal::AffineBasis< TPoint >::SHORTEST_ECHELON_REDUCED.
|
inline |
Constructor from points.
| [in] | points | the range of points belonging to the affine space. |
| [in] | type | if Type::ECHELON_REDUCED or Type::SHORTEST_ECHELON_REDUCED, reduces the basis so that it forms a echelon matrix, otherwise computes its delta-LLL-lattice. |
| [in] | delta | the parameter \( \delta \) of LLL-algorithm, which should be between 0.25 and 1 (value 0.99 is default in sagemath). |
| [in] | tolerance | the accepted oo-norm below which the vector is null (used only for points with float/double coordinates). |
Definition at line 164 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::basis(), DGtal::AffineBasis< TPoint >::first, DGtal::AffineBasis< TPoint >::initBasis(), DGtal::AffineBasis< TPoint >::reduce(), and DGtal::AffineGeometry< TPoint >::transform().
|
inline |
Constructor from origin and basis.
| [in] | origin | the origin of the affine basis |
| [in] | basis | the range of vectors forming the basis |
| [in] | type | if Type::ECHELON_REDUCED or Type::SHORTEST_ECHELON_REDUCED, reduces the basis so that it forms a echelon matrix, otherwise computes its delta-LLL-lattice. |
| [in] | is_reduced | when 'true', assumes that the given basis is already reduced, otherwise it forces the reduction of the basis. |
| [in] | delta | the parameter \( \delta \) of LLL-algorithm, which should be between 0.25 and 1 (value 0.99 is default in sagemath). |
| [in] | tolerance | the accepted oo-norm below which the vector is null (used only for points with float/double coordinates). |
Definition at line 201 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, DGtal::AffineBasis< TPoint >::basis(), DGtal::AffineBasis< TPoint >::first, DGtal::AffineBasis< TPoint >::initBasis(), DGtal::AffineBasis< TPoint >::origin(), DGtal::AffineBasis< TPoint >::reduce(), and DGtal::AffineGeometry< TPoint >::transform().
|
inline |
Creates an affine basis going through origin and orthogonal to the lattice vector normal.
| [in] | origin | the origin of the affine basis |
| [in] | normal | the lattice normal vector. |
| [in] | type | if Type::ECHELON_REDUCED or Type::SHORTEST_ECHELON_REDUCED, then the basis will be in echelon form, otherwise it will make the vectors as short as possible, but the matrix won't be in echelon form. |
| [in] | tolerance | the accepted oo-norm below which the vector is null (used only for points with float/double coordinates). |
Definition at line 230 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, DGtal::AffineBasis< TPoint >::ECHELON_REDUCED, DGtal::AffineBasis< TPoint >::first, DGtal::AffineBasis< TPoint >::LLL_REDUCED, DGtal::AffineBasis< TPoint >::origin(), DGtal::AffineGeometry< TPoint >::orthogonalLatticeBasis(), DGtal::AffineBasis< TPoint >::second, and DGtal::AffineGeometry< TPoint >::transform().
|
inline |
Definition at line 284 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::second.
Referenced by DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::findIndexWithSmallestNonNullComponent(), and DGtal::AffineBasis< TPoint >::initBasis().
|
inline |
Decompose p as d * (p - o) = l[0]b[0] + ... l[i]b[i] + r, where r is independent from this basis B=(b[0],...,b[i]).
| [in] | p | any point. |
Definition at line 401 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::decomposeVector(), and DGtal::AffineBasis< TPoint >::first.
Referenced by DGtal::AffineBasis< TPoint >::isOnAffineSpace(), DGtal::AffineBasis< TPoint >::projectPoints(), and DGtal::AffineBasis< TPoint >::rationalCoordinates().
|
inline |
Decompose w as d * w = l[0]b[0] + ... l[i]b[i] + r, where r is independent from B=(b[0],...,b[i]).
| [in] | w | any vector. |
Definition at line 414 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::epsilon, DGtal::AffineGeometry< TPoint >::reduceVector(), and DGtal::AffineBasis< TPoint >::second.
Referenced by DGtal::AffineBasis< TPoint >::decompose(), and DGtal::AffineBasis< TPoint >::isParallel().
|
inlinestatic |
Transforms the type of an input point into another one, while dilating it by a factor m.
| OtherPoint | a type of point of dimension at most Point::dimension. |
| [out] | pp | the output restricted point. |
| [in] | p | the input point. |
| [in] | m | the dilation factor. |
Definition at line 492 of file AffineBasis.h.
Referenced by DGtal::AffineBasis< TPoint >::projectPoints().
|
inline |
Definition at line 271 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::second.
Referenced by DGtal::AffineBasis< TPoint >::isParallel().
|
inlineprotected |
Given a range of points basis, starting from rank i, find the index of the point with lowest non null k-th coefficient in absolute value, or basis.size() if every point had its k-th component null.
| [in] | k | the component/coordinate of interest |
| [in] | i | the starting index |
| [in] | basis | a range of points/vectors |
Definition at line 708 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::basis(), DGtal::AffineBasis< TPoint >::epsilon, and index().
Referenced by DGtal::AffineBasis< TPoint >::reduceAsEchelon().
|
inlineprotected |
Removes null vectors from input set of vectors and sets the initial basis.
| TInputPoint | the type of input points |
| [in] | basis | a set of arbitrary vectors |
Definition at line 660 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::basis(), DGtal::AffineBasis< TPoint >::second, and DGtal::AffineGeometry< TPoint >::transform().
Referenced by DGtal::AffineBasis< TPoint >::AffineBasis(), and DGtal::AffineBasis< TPoint >::AffineBasis().
|
inline |
| [in] | p | any lattice point |
Definition at line 326 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::decompose(), and DGtal::AffineBasis< TPoint >::epsilon.
|
inline |
| [in] | w | any lattice vector |
Definition at line 336 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::decomposeVector(), and DGtal::AffineBasis< TPoint >::epsilon.
|
inline |
| [in] | other | an other affine basis |
Definition at line 299 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, DGtal::AffineBasis< TPoint >::dimension(), DGtal::AffineBasis< TPoint >::ECHELON_REDUCED, DGtal::Trace::error(), DGtal::AffineBasis< TPoint >::isParallel(), DGtal::AffineBasis< TPoint >::reductionTypeName(), DGtal::AffineBasis< TPoint >::second, DGtal::AffineBasis< TPoint >::SHORTEST_ECHELON_REDUCED, and DGtal::trace.
Referenced by DGtal::AffineBasis< TPoint >::isParallel().
|
inline |
Definition at line 520 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, and DGtal::AffineBasis< TPoint >::INVALID.
|
inlineprotected |
If the basis is an integer lattice, reduces the basis vectors by their gcd, otherwise normalize vectors to have 1 L2-norm.
Definition at line 554 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::second, and DGtal::AffineGeometry< TPoint >::simplifiedVector().
Referenced by DGtal::AffineBasis< TPoint >::sortBasis().
|
inlineprotected |
Guarantees that the basis is in echelon form.
Definition at line 596 of file AffineBasis.h.
References compare(), DGtal::AffineBasis< TPoint >::epsilon, and DGtal::AffineBasis< TPoint >::second.
Referenced by DGtal::AffineBasis< TPoint >::reduceAsEchelon().
|
inline |
Definition at line 277 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::first.
Referenced by DGtal::AffineBasis< TPoint >::AffineBasis(), and DGtal::AffineBasis< TPoint >::AffineBasis().
|
inline |
Projects the range of points input onto the affine basis and outputs it in result. A consistent choice for ProjectedPoint is to match the affine dimension.
| ProjectedPoint | a type of point that matches the affine dimension. |
| [out] | result | the range of projected points. |
| [in] | input | the range of input points |
Definition at line 444 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::decompose(), and DGtal::AffineBasis< TPoint >::dilatedTransform().
|
inline |
| [in] | p | any lattice point |
L/d as a pair (d, L) in this affine basis, where L is a lattice vector and d is the common denominator for the components of L. Definition at line 316 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::decompose().
|
inline |
Given (d, lambda, r), recompose the point p such that d * (p - o) = l[0]b[0] + ... l[i]b[i] + r. Given only the rational coordinates (d,lambda), the point is assumed to lie on this affine space (i.e. r == 0 ).
| [in] | d | the common denominator that defines the rational coordinates with lambda. |
| [in] | lambda | the numerators that defines the rational coordinates with d. |
| [in] | r | the remainder vector (r is independent from this basis B=(b[0],...,b[i])), which represents the displacement from p to this affine space. |
p such that d * (p - o) = B lambda + r, for B the vectors of this basis (arranged as rows in matrix) and o its origin. Definition at line 360 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::first, and DGtal::AffineBasis< TPoint >::recomposeVector().
|
inline |
Given (d, lambda, r), recompose the vector w such that d * w = l[0]b[0] + ... l[i]b[i] + r. Given only the rational coordinates (d,lambda), the vector is assumed to be parallel to this affine space (i.e. r == 0 ).
| [in] | d | the common denominator that defines the rational coordinates with lambda. |
| [in] | lambda | the numerators that defines the rational coordinates with d. |
| [in] | r | the remainder vector (r is independent from this basis B=(b[0],...,b[i])), which represents the displacement vector to this vector space. |
p such that d * w = B lambda + r, for B the vectors of this basis (arranged as rows in matrix) and o its origin. Definition at line 384 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::second.
Referenced by DGtal::AffineBasis< TPoint >::recompose().
|
inline |
Reduces the basis into a set of a linearly independent vectors, and in the desired reduced form.
| [in] | type | the desired type of matrix reduction. |
| [in] | delta | the parameter \( \delta \) of LLL-algorithm, which should be between 0.25 and 1 (value 0.99 is default in sagemath). |
Definition at line 252 of file AffineBasis.h.
References DGtal::AffineGeometry< TPoint >::affineBasis(), DGtal::AffineBasis< TPoint >::ECHELON_REDUCED, DGtal::AffineBasis< TPoint >::epsilon, DGtal::AffineBasis< TPoint >::first, DGtal::AffineBasis< TPoint >::LLL_REDUCED, DGtal::AffineBasis< TPoint >::reduceAsEchelon(), DGtal::AffineBasis< TPoint >::reduceAsLLL(), DGtal::AffineBasis< TPoint >::second, DGtal::AffineBasis< TPoint >::SHORTEST_ECHELON_REDUCED, and DGtal::AffineBasis< TPoint >::sortBasis().
Referenced by DGtal::AffineBasis< TPoint >::AffineBasis(), and DGtal::AffineBasis< TPoint >::AffineBasis().
|
inlineprotected |
Reduces the basis so that each basis vector is normalized, removes linearly dependent vectors, and builds a echelon matrix.
Definition at line 562 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, DGtal::AffineBasis< TPoint >::epsilon, DGtal::AffineBasis< TPoint >::findIndexWithSmallestNonNullComponent(), DGtal::AffineBasis< TPoint >::orderEchelonBasis(), DGtal::AffineGeometry< TPoint >::reduceVector(), DGtal::AffineBasis< TPoint >::second, and DGtal::AffineGeometry< TPoint >::simplifiedVector().
Referenced by DGtal::AffineBasis< TPoint >::reduce().
|
inlineprotected |
Reduces the basis so that each basis vector is normalized, then computes its delta-LLL-reduction lattice, and removes linearly dependent vectors.
| [in] | delta | the parameter \( \delta \) of LLL-algorithm, which should be between 0.25 and 1 (value 0.99 is default in sagemath). |
keep only independent vectors in basis
Definition at line 622 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, DGtal::Trace::error(), DGtal::AffineBasis< TPoint >::INVALID, DGtal::AffineBasis< TPoint >::LLL_REDUCED, DGtal::functions::reduceBasisWithLLL(), DGtal::AffineBasis< TPoint >::second, DGtal::AffineGeometry< TPoint >::simplifiedVector(), and DGtal::trace.
Referenced by DGtal::AffineBasis< TPoint >::reduce().
|
inline |
Definition at line 526 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::_type, DGtal::AffineBasis< TPoint >::ECHELON_REDUCED, DGtal::AffineBasis< TPoint >::INVALID, DGtal::AffineBasis< TPoint >::LLL_REDUCED, and DGtal::AffineBasis< TPoint >::SHORTEST_ECHELON_REDUCED.
Referenced by DGtal::AffineBasis< TPoint >::isParallel(), and DGtal::AffineBasis< TPoint >::selfDisplay().
|
inline |
Displays this object on the output stream.
| [in,out] | out | any output stream. |
Definition at line 509 of file AffineBasis.h.
References DGtal::AffineBasis< TPoint >::first, DGtal::AffineBasis< TPoint >::reductionTypeName(), and DGtal::AffineBasis< TPoint >::second.
Referenced by DGtal::operator<<().
|
inlineprotected |
Simplifies vectors, removes duplicates and puts smallest candidate basis vectors before longest.
Definition at line 672 of file AffineBasis.h.
References compare(), DGtal::AffineBasis< TPoint >::normalize(), and DGtal::AffineBasis< TPoint >::second.
Referenced by DGtal::AffineBasis< TPoint >::reduce().
|
inlinestatic |
Transforms the type of an input point into another one.
| OtherPoint | a type of point of dimension at most Point::dimension. |
| [out] | pp | the output restricted point. |
| [in] | p | the input point. |
Definition at line 475 of file AffineBasis.h.
| AffineBasis::Type DGtal::AffineBasis< TPoint >::_type |
the type of reduction of the basis.
Definition at line 544 of file AffineBasis.h.
Referenced by DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::isParallel(), DGtal::AffineBasis< TPoint >::isValid(), DGtal::AffineBasis< TPoint >::reduceAsEchelon(), DGtal::AffineBasis< TPoint >::reduceAsLLL(), and DGtal::AffineBasis< TPoint >::reductionTypeName().
| double DGtal::AffineBasis< TPoint >::epsilon {1e-12} |
the accepted value below which a floating-point number is 0.
Definition at line 543 of file AffineBasis.h.
Referenced by DGtal::AffineBasis< TPoint >::decomposeVector(), DGtal::AffineBasis< TPoint >::findIndexWithSmallestNonNullComponent(), DGtal::AffineBasis< TPoint >::isOnAffineSpace(), DGtal::AffineBasis< TPoint >::isParallel(), DGtal::AffineBasis< TPoint >::orderEchelonBasis(), DGtal::AffineBasis< TPoint >::reduce(), and DGtal::AffineBasis< TPoint >::reduceAsEchelon().
| Point DGtal::AffineBasis< TPoint >::first |
the origin of the affine basis
Definition at line 541 of file AffineBasis.h.
Referenced by DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::decompose(), DGtal::AffineBasis< TPoint >::origin(), DGtal::AffineBasis< TPoint >::recompose(), DGtal::AffineBasis< TPoint >::reduce(), and DGtal::AffineBasis< TPoint >::selfDisplay().
| Points DGtal::AffineBasis< TPoint >::second |
the vector basis
Definition at line 542 of file AffineBasis.h.
Referenced by DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::AffineBasis(), DGtal::AffineBasis< TPoint >::basis(), DGtal::AffineBasis< TPoint >::decomposeVector(), DGtal::AffineBasis< TPoint >::dimension(), DGtal::AffineBasis< TPoint >::initBasis(), DGtal::AffineBasis< TPoint >::isParallel(), DGtal::AffineBasis< TPoint >::normalize(), DGtal::AffineBasis< TPoint >::orderEchelonBasis(), DGtal::AffineBasis< TPoint >::recomposeVector(), DGtal::AffineBasis< TPoint >::reduce(), DGtal::AffineBasis< TPoint >::reduceAsEchelon(), DGtal::AffineBasis< TPoint >::reduceAsLLL(), DGtal::AffineBasis< TPoint >::selfDisplay(), and DGtal::AffineBasis< TPoint >::sortBasis().