CGAL::linear_least_squares_fitting_3

Definition

The function linear_least_squares_fitting_3 computes the best fitting 3D line or plane of 3D point sets or triangle sets. The best fit linear sub-space minimizes the sum of squared distances from the points to their projections onto the sub-space.

#include <CGAL/linear_least_squares_fitting_3.h>

template < typename InputIterator, typename K>
typename K::FT
linear_least_squares_fitting_3 ( InputIterator first,
InputIterator beyond,
typename K::Line_3 & line,
typename K::Point_3 & centroid,
K k)
computes the best fitting 3D line of a 3D point set or triangle set in the range [first,beyond). The value returned is a fitting quality between 0 and 1, where 0 means that the variance is the same along any line (a horizontal line going through the centroid is output by default), and 1 means that the variance is null orthogonally to the best fitting line.

The class K is the kernel in which the type InputIterator::value_type is defined. It can be omitted and deduced automatically from the value type.

Requirements

  1. InputIterator::value_type is equivalent to K::Point_3 or K::Triangle_3.
  2. line is the best fitting line computed.
  3. centroid is the centroid computed. This parameter can be omitted.

template < typename InputIterator, typename K>
typename K::FT
linear_least_squares_fitting_3 ( InputIterator first,
InputIterator beyond,
typename K::Plane_3 & plane,
typename K::Point_3 & centroid,
K k)
computes the best fitting 3D plane of a 3D point set or triangle set in the range [first,beyond). The value returned is a fitting quality between 0 and 1, where 0 means that the variance is the same along any plane (a horizontal plane going through the centroid is output by default), and 1 means that the variance is null orthogonally to the best fitting plane.

The class K is the kernel in which the type InputIterator::value_type is defined. It can be omitted and deduced automatically from the value type.

Requirements

  1. InputIterator::value_type is equivalent to K::Point_3 or K::Triangle_3.
  2. plane is the best fitting plane computed.
  3. centroid is the centroid computed. This parameter can be omitted.