\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)

CGAL 4.8 - Principal Component Analysis

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
CGAL::barycenter()
Principal Component Analysis Reference

##

The function `barycenter()` computes the barycenter (weighted center of mass) of a set of 2D or 3D weighted points.

The weight associated to each point is specified using a `std::pair` storing the point and its weight.

There is a set of overloaded `barycenter` functions for 2D and 3D weighted points. The user can also optionally pass an explicit kernel, in case the default, based on `Kernel_traits` is not sufficient. The dimension is also deduced automatically.

See Also
  `CGAL::centroid()`
  `CGAL::barycenter() (Linear Kernel)`

## Functions
template<typename InputIterator >
Deduced | CGAL::barycenter (InputIterator first, InputIterator beyond)
| computes the barycenter of a non-empty set of 2D or 3D weighted points. More...
template<typename InputIterator , typename K >
Deduced | CGAL::barycenter (InputIterator first, InputIterator beyond, const K &k)
| computes the barycenter of a non-empty set of 2D or 3D weighted points. More...

## Function Documentation

template<typename InputIterator >

Deduced CGAL::barycenter | ( | InputIterator | first,
|  | InputIterator | beyond
| ) |  |

computes the barycenter of a non-empty set of 2D or 3D weighted points.

Returns
  `K::Point_2` or `K::Point_3` depending on the dimension of the input values, where `K` is
  CGAL::Kernel_traits<
  std::iterator_traits<InputIterator>::value_type::first_type
  >::Kernel

Template Parameters

  InputIterator | must have `std::pair<K::Point_2, K::FT>` or `std::pair<K::Point_3, K::FT> as value type`.

Precondition
  first != beyond, and the sum of the weights is non-zero.

`#include <CGAL/barycenter.h>`

template<typename InputIterator , typename K >

Deduced CGAL::barycenter | ( | InputIterator | first,
|  | InputIterator | beyond,
|  | const K & | k
| ) |  |

computes the barycenter of a non-empty set of 2D or 3D weighted points.

Returns
  `K::Point_2` or `K::Point_3` depending on the dimension of the input values.

Template Parameters

  InputIterator | must have `std::pair<K::Point_2, K::FT>` or `std::pair<K::Point_3, K::FT>` as value type.

Precondition
  first != beyond, and the sum of the weights is non-zero.

`#include <CGAL/barycenter.h>`