mirror of https://github.com/CGAL/cgal
Use CGAL::centroid() instead of a duplicated code.
This commit is contained in:
parent
07e470978e
commit
60d068d880
|
|
@ -29,7 +29,7 @@
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
template < class Kernel >
|
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::Point_2 Point_2;
|
||||||
typedef typename Kernel::Direction_2 Direction_2;
|
typedef typename Kernel::Direction_2 Direction_2;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <CGAL/Random_convex_set_traits_2.h>
|
#include <CGAL/Random_convex_set_traits_2.h>
|
||||||
|
#include <CGAL/centroid.h>
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -73,10 +74,7 @@ random_convex_set_2( int n,
|
||||||
CGAL::copy_n( pg, n, back_inserter( points));
|
CGAL::copy_n( pg, n, back_inserter( points));
|
||||||
|
|
||||||
// compute centroid of points:
|
// compute centroid of points:
|
||||||
Point_2 centroid(
|
Point_2 centroid = CGAL::centroid( points.begin(), points.end(), t );
|
||||||
scale(
|
|
||||||
accumulate( points.begin(), points.end(), t.origin(), Sum()),
|
|
||||||
FT( 1) / FT( n)));
|
|
||||||
|
|
||||||
// translate s.t. centroid == origin:
|
// translate s.t. centroid == origin:
|
||||||
transform(
|
transform(
|
||||||
|
|
@ -94,10 +92,7 @@ random_convex_set_2( int n,
|
||||||
points.begin(), points.end(), points.begin(), Sum());
|
points.begin(), points.end(), points.begin(), Sum());
|
||||||
|
|
||||||
// and compute its centroid:
|
// and compute its centroid:
|
||||||
Point_2 new_centroid(
|
Point_2 new_centroid = CGAL::centroid( points.begin(), points.end(), t );
|
||||||
scale(
|
|
||||||
accumulate( points.begin(), points.end(), t.origin(), Sum()),
|
|
||||||
FT( 1) / FT( n)));
|
|
||||||
|
|
||||||
// translate s.t. centroids match:
|
// translate s.t. centroids match:
|
||||||
transform(
|
transform(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue