|
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. |
). It is not handy for solving
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 _type, epsilon, first, second, and 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 basis(), epsilon, first, for(), initBasis(), reduce(), and DGtal::AffineGeometry< Point >::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 _type, basis(), epsilon, first, initBasis(), origin(), reduce(), and DGtal::AffineGeometry< Point >::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 _type, ECHELON_REDUCED, epsilon, first, LLL_REDUCED, origin(), DGtal::AffineGeometry< Point >::orthogonalLatticeBasis(), second, and DGtal::AffineGeometry< Point >::transform().
|
inline |
Definition at line 284 of file AffineBasis.h.
References second.
Referenced by AffineBasis(), AffineBasis(), findIndexWithSmallestNonNullComponent(), and 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 decomposeVector(), and first.
Referenced by isOnAffineSpace(), projectPoints(), and 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 epsilon, DGtal::AffineGeometry< Point >::reduceVector(), and second.
Referenced by decompose(), and 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 projectPoints().
|
inline |
Definition at line 271 of file AffineBasis.h.
References second.
Referenced by 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 basis(), epsilon, and index().
Referenced by 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 basis(), second, and DGtal::AffineGeometry< Point >::transform().
Referenced by AffineBasis(), and AffineBasis().
|
inline |
| [in] | p | any lattice point |
Definition at line 326 of file AffineBasis.h.
References decompose(), and epsilon.
|
inline |
| [in] | w | any lattice vector |
Definition at line 336 of file AffineBasis.h.
References decomposeVector(), and epsilon.
|
inline |
| [in] | other | an other affine basis |
Definition at line 299 of file AffineBasis.h.
References _type, dimension(), ECHELON_REDUCED, isParallel(), reductionTypeName(), second, SHORTEST_ECHELON_REDUCED, and DGtal::trace.
Referenced by isParallel().
|
inline |
Definition at line 520 of file AffineBasis.h.
|
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 second, and DGtal::AffineGeometry< Point >::simplifiedVector().
Referenced by sortBasis().
|
inlineprotected |
Guarantees that the basis is in echelon form.
Definition at line 596 of file AffineBasis.h.
References compare(), epsilon, and second.
Referenced by reduceAsEchelon().
|
inline |
Definition at line 277 of file AffineBasis.h.
References first.
Referenced by AffineBasis(), and 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 decompose(), and dilatedTransform().
|
inline |
| [in] | p | any lattice point |
Definition at line 316 of file AffineBasis.h.
References 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. |
Definition at line 360 of file AffineBasis.h.
References first, and 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. |
Definition at line 384 of file AffineBasis.h.
References second.
Referenced by 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(), ECHELON_REDUCED, epsilon, first, LLL_REDUCED, reduceAsEchelon(), reduceAsLLL(), second, SHORTEST_ECHELON_REDUCED, and sortBasis().
Referenced by AffineBasis(), and 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 _type, epsilon, findIndexWithSmallestNonNullComponent(), orderEchelonBasis(), DGtal::AffineGeometry< Point >::reduceVector(), second, and DGtal::AffineGeometry< Point >::simplifiedVector().
Referenced by 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 _type, INVALID, LLL_REDUCED, DGtal::functions::reduceBasisWithLLL(), second, DGtal::AffineGeometry< Point >::simplifiedVector(), and DGtal::trace.
Referenced by reduce().
|
inline |
Definition at line 526 of file AffineBasis.h.
References _type, ECHELON_REDUCED, INVALID, LLL_REDUCED, and SHORTEST_ECHELON_REDUCED.
Referenced by isParallel(), and selfDisplay().
|
inline |
Displays this object on the output stream.
| [in,out] | out | any output stream. |
Definition at line 509 of file AffineBasis.h.
References first, reductionTypeName(), and second.
|
inlineprotected |
Simplifies vectors, removes duplicates and puts smallest candidate basis vectors before longest.
Definition at line 672 of file AffineBasis.h.
References compare(), normalize(), and second.
Referenced by 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 AffineBasis(), AffineBasis(), AffineBasis(), isParallel(), isValid(), reduceAsEchelon(), reduceAsLLL(), and 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 AffineBasis(), AffineBasis(), AffineBasis(), AffineBasis(), decomposeVector(), findIndexWithSmallestNonNullComponent(), isOnAffineSpace(), isParallel(), orderEchelonBasis(), reduce(), and reduceAsEchelon().
| Point DGtal::AffineBasis< TPoint >::first |
the origin of the affine basis
Definition at line 541 of file AffineBasis.h.
Referenced by AffineBasis(), AffineBasis(), AffineBasis(), AffineBasis(), decompose(), origin(), recompose(), reduce(), and selfDisplay().
| Points DGtal::AffineBasis< TPoint >::second |
the vector basis
Definition at line 542 of file AffineBasis.h.
Referenced by AffineBasis(), AffineBasis(), basis(), decomposeVector(), dimension(), initBasis(), isParallel(), normalize(), orderEchelonBasis(), recomposeVector(), reduce(), reduceAsEchelon(), reduceAsLLL(), selfDisplay(), and sortBasis().