CGAL 5.1 - Geometric Object Generators
Generator/random_grid.cpp
#include <CGAL/Simple_cartesian.h>
#include <cassert>
#include <vector>
#include <algorithm>
#include <CGAL/point_generators_2.h>
#include <CGAL/algorithm.h>
using namespace CGAL;
typedef K::Point_2 Point;
int main() {
// Create test point set. Prepare a vector for 400 points.
std::vector<Point> points;
points.reserve(400);
// Create 250 points from a 16 x 16 grid. Note that the double
// arithmetic _is_ sufficient to produce exact integer grid points.
// The distance between neighbors is 34 pixel = 510 / 15.
points_on_square_grid_2( 255.0, 250, std::back_inserter(points),Creator());
// Lower, left corner.
assert( points[0].x() == -255);
assert( points[0].y() == -255);
// Upper, right corner. Note that 6 points are missing to fill the grid.
assert( points[249].x() == 255 - 6 * 34);
assert( points[249].y() == 255);
// Create 250 points within a disc of radius 150.
std::copy_n( g, 250, std::back_inserter(points));
// Check that we have really created 500 points.
assert( points.size() == 500);
return 0;
}
CGAL::Random_points_in_disc_2
The class Random_points_in_disc_2 is an input iterator creating points uniformly distributed in an op...
Definition: point_generators_2.h:158
CGAL::points_on_square_grid_2
OutputIterator points_on_square_grid_2(double a, std::size_t n, OutputIterator o, Creator creator=Creator_uniform_2< Kernel_traits< P >::Kernel::RT, P >)
generates a given number of points on a square grid whose size is determined by the number of points ...
CGAL::Creator_uniform_2
CGAL
copy_n
OutputIterator copy_n(InputIterator first, Size n, OutputIterator result)
CGAL::Simple_cartesian