Algorithmic Solutions > LEDA > LEDA Guide > Geometry > Generators for Geometric Objects > Example Point Generators
Example Generators for Random PointsThe following example shows how to use the generators for #include <LEDA/geo/point.h>
#include <LEDA/geo/rat_point.h>
#include <LEDA/geo/random_point.h>
#include <LEDA/geo/random_rat_point.h>
using namespace leda;
int main()
{
point p;
random_point_in_square(p,10);
std::cout << p.to_point() << std::endl;
//returns a point whose x- and y-coordinates are random integers
//in [- 10..10].
list<rat_point> L;
random_points_in_unit_square(3,2000,L);
rat_point rp;
forall(rp,L) std::cout << rp.to_point() << " ";
std::cout << std::endl;
//returns a list L of 3 points whose coordinates are random
//rationals of the form i/2000 where i is a random integer
//in the range [0..2000].
return 0;
}
|
See also:Generators for Geometric Objects Advanced Data types for 2-D geometry Manual Entries: |