The function barycenter computes the barycenter (weighted center of mass) of a set of weighted 2D or 3D objects. The weight associated to each object is specified using a std::pair storing the object and its weight.
#include <CGAL/barycenter.h>
There is a set of overloaded barycenter functions for 2D and 3D weighted objects. 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.
 

 
computes the barycenter of a nonempty set of 2D weighted points.
K is Kernel_traits<std::iterator_traits<InputIterator>::value_type::first_type>::Kernel.
The value type must be std::pair<K::Point_2, K::FT>. Precondition: first != beyond, and the sum of the weights is nonzero.  
 

 
computes the barycenter of a nonempty set of 2D weighted points.
The value type must be std::pair<K::Point_2, K::FT>. Precondition: first != beyond, and the sum of the weights is nonzero.  
 

 
computes the barycenter of a nonempty set of 3D weighted points.
K is Kernel_traits<std::iterator_traits<InputIterator>::value_type::first_type>::Kernel.
The value type must be std::pair<K::Point_3, K::FT>. Precondition: first != beyond, and the sum of the weights is nonzero.  
 

 
computes the barycenter of a nonempty set of 3D weighted points.
The value type must be std::pair<K::Point_3, K::FT>. Precondition: first != beyond, and the sum of the weights is nonzero. 