Easy3D 2.6.1
Loading...
Searching...
No Matches
PrincipalAxes< DIM, FT > Class Template Reference

Computes the principal axes for a set of 2D or 3D points. More...

#include <easy3d/core/principal_axes.h>

Public Member Functions

 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.
 

Detailed Description

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
DIMThe spatial dimension (must be either 2 or 3).
FTThe 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.

Member Function Documentation

◆ 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
FT2The type of the point's coordinates.
Parameters
pThe point to be added.
weightThe 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
InputIteratorThe type of the input iterator.
Parameters
firstThe beginning of the range of points.
lastThe 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
FT2The type of the floating-point number for the result.
Parameters
iThe index of the axis.
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

center = pca.center<float>();
Vec< DIM, FT2 > center() const
The weighted average of the points.
Definition principal_axes.h:138
Template Parameters
FT2The 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
iThe 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: