Use CGAL::centroid() instead of a duplicated code.

This commit is contained in:
Sylvain Pion 2008-04-15 16:03:13 +00:00
parent 07e470978e
commit 60d068d880
2 changed files with 4 additions and 9 deletions

View File

@ -29,7 +29,7 @@
CGAL_BEGIN_NAMESPACE
template < class Kernel >
struct Random_convex_set_traits_2 {
struct Random_convex_set_traits_2 : public Kernel {
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Direction_2 Direction_2;

View File

@ -30,6 +30,7 @@
#include <algorithm>
#include <numeric>
#include <CGAL/Random_convex_set_traits_2.h>
#include <CGAL/centroid.h>
CGAL_BEGIN_NAMESPACE
@ -73,10 +74,7 @@ random_convex_set_2( int n,
CGAL::copy_n( pg, n, back_inserter( points));
// compute centroid of points:
Point_2 centroid(
scale(
accumulate( points.begin(), points.end(), t.origin(), Sum()),
FT( 1) / FT( n)));
Point_2 centroid = CGAL::centroid( points.begin(), points.end(), t );
// translate s.t. centroid == origin:
transform(
@ -94,10 +92,7 @@ random_convex_set_2( int n,
points.begin(), points.end(), points.begin(), Sum());
// and compute its centroid:
Point_2 new_centroid(
scale(
accumulate( points.begin(), points.end(), t.origin(), Sum()),
FT( 1) / FT( n)));
Point_2 new_centroid = CGAL::centroid( points.begin(), points.end(), t );
// translate s.t. centroids match:
transform(