Algorithmic Solutions > LEDA > LEDA Guide > Geometry > Generators for Geometric Objects > Example Point Generators


Example Generators for Random Points

The following example shows how to use the generators for points and rat_points.

#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:

Data Types for 2D Geometry

Linear Lists


Generators for Geometric Objects

Geometry

Advanced Data types for 2-D geometry

Geometry Algorithms

GeoWin


Manual Entries:

Manual Page Point Generators




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH