Computes the principal axes for a set of 2D or 3D points.
More...
#include <easy3d/core/principal_axes.h>
|
|
| PrincipalAxes () |
| | Default constructor.
|
| |
|
| ~PrincipalAxes ()=default |
| | Destructor.
|
| |
|
void | begin () |
| | Begins adding points.
|
| |
| template<typename FT2> |
| void | add (const Vec< DIM, FT2 > &p, FT2 weight=FT2(1)) |
| | Adds a point p with a weight.
|
| |
|
void | end () |
| | Ends adding points.
|
| |
| template<typename InputIterator> |
| void | add (InputIterator first, InputIterator last) |
| | Adds a set of points (internally it iteratively calls add()).
|
| |
| template<typename FT2> |
| Vec< DIM, FT2 > | center () const |
| | The weighted average of the points.
|
| |
| template<typename FT2> |
| Vec< DIM, FT2 > | axis (int i) const |
| | The i_th axis.
|
| |
| FT | eigen_value (int i) const |
| | The i_th eigenvalue.
|
| |
template<int DIM, typename FT = double>
class easy3d::PrincipalAxes< DIM, FT >
Computes the principal axes for a set of 2D or 3D points.
- Template Parameters
-
| DIM | The spatial dimension (must be either 2 or 3). |
| FT | The floating-point type used for computations (float or double). Defaults to 'double'. |
- Note
- Using 'float' may lead to significant numerical errors, especially when processing a large number of points with varying coordinate scales, due to floating-point precision limitations.
- Todo
- Test support for 2D cases.
◆ add() [1/2]
template<int DIM, typename FT>
template<typename FT2>
| void add |
( |
const Vec< DIM, FT2 > & | p, |
|
|
FT2 | weight = FT2(1) ) |
Adds a point p with a weight.
This function supports different types of vectors, e.g. vec3, dvec3, and ivec3.
- Template Parameters
-
| FT2 | The type of the point's coordinates. |
- Parameters
-
| p | The point to be added. |
| weight | The weight of the point (default is 1). |
◆ add() [2/2]
template<int DIM, typename FT>
template<typename InputIterator>
| void add |
( |
InputIterator | first, |
|
|
InputIterator | last ) |
Adds a set of points (internally it iteratively calls add()).
- Template Parameters
-
| InputIterator | The type of the input iterator. |
- Parameters
-
| first | The beginning of the range of points. |
| last | The end of the range of points. |
◆ axis()
template<int DIM, typename FT>
template<typename FT2>
| Vec< DIM, FT2 > axis |
( |
int | i | ) |
const |
The i_th axis.
This function supports different types of vectors, e.g. vec3 and dvec. To call this function, use
normal = pca.axis<float>(2);
- Template Parameters
-
| FT2 | The type of the floating-point number for the result. |
- Parameters
-
- Returns
- The
i_th axis.
- Note
- The eigenvectors are sorted in accordance with eigenvalues stored in the descending order.
◆ center()
template<int DIM, typename FT>
template<typename FT2>
| Vec< DIM, FT2 > center |
( |
| ) |
const |
The weighted average of the points.
This function supports different types of vectors, e.g. vec3, dvec3. To call this function, use
Vec< DIM, FT2 > center() const
The weighted average of the points.
Definition principal_axes.h:138
- Template Parameters
-
| FT2 | The type of the floating-point number for the result. |
- Returns
- The center of the points.
◆ eigen_value()
template<int DIM, typename FT>
| FT eigen_value |
( |
int | i | ) |
const |
The i_th eigenvalue.
- Parameters
-
| i | The index of the eigenvalue. |
- Returns
- The
i_th eigenvalue.
- Note
- The eigenvalues are sorted in descending order.
The documentation for this class was generated from the following file: