CGAL::centroid

Definition

The function centroid computes the centroid (center of mass) of a set of 2D or 3D objects.

#include <CGAL/centroid.h>

There is a set of overloaded centroid functions for 2D and 3D 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.

template < typename InputIterator >
K::Point_2 centroid ( InputIterator first, InputIterator beyond)
computes the centroid of a non-empty set of 2D points. K is Kernel_traits<std::iterator_traits<InputIterator>::value_type>::Kernel. The value type must be K::Point_2.
Precondition: first != beyond.

template < typename InputIterator, typename K >
K::Point_2 centroid ( InputIterator first, InputIterator beyond, K k)
computes the centroid of a non-empty set of 2D points. The value type must be K::Point_2.
Precondition: first != beyond.

template < typename InputIterator >
K::Point_3 centroid ( InputIterator first, InputIterator beyond)
computes the centroid of a non-empty set of 3D points. K is Kernel_traits<std::iterator_traits<InputIterator>::value_type>::Kernel. The value type must be K::Point_3.
Precondition: first != beyond.

template < typename InputIterator, typename K >
K::Point_3 centroid ( InputIterator first, InputIterator beyond, K k)
computes the centroid of a non-empty set of 3D points. The value type must be K::Point_3.
Precondition: first != beyond.

See Also

CGAL::barycenter